Class AbstractObservationTest
- java.lang.Object
-
- junit.framework.Assert
-
- junit.framework.TestCase
-
- org.apache.jackrabbit.test.JUnitTest
-
- org.apache.jackrabbit.test.AbstractJCRTest
-
- org.apache.jackrabbit.test.api.observation.AbstractObservationTest
-
- All Implemented Interfaces:
junit.framework.Test
- Direct Known Subclasses:
AddEventListenerTest,EventIteratorTest,EventJournalTest,EventTest,GetDateTest,GetIdentifierTest,GetInfoTest,GetRegisteredEventListenersTest,GetUserDataTest,LockingTest,NodeAddedTest,NodeMovedTest,NodeRemovedTest,NodeReorderTest,PropertyAddedTest,PropertyChangedTest,PropertyRemovedTest,WorkspaceOperationTest
public abstract class AbstractObservationTest extends AbstractJCRTest
This class implements the basicsetUp()andtearDown()methods for the observation test cases.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interfaceAbstractObservationTest.CallableHelper interface.
-
Field Summary
Fields Modifier and Type Field Description protected static intALL_TYPESprotected static longDEFAULT_WAIT_TIMEOUTDefault wait timeout for events: 5000 msprotected ObservationManagerobsMgrTheObservationManager-
Fields inherited from class org.apache.jackrabbit.test.AbstractJCRTest
isReadOnly, jcrBaseVersion, jcrCopiedFrom, jcrCreated, jcrFrozenNode, jcrFrozenUuid, jcrIsCheckedOut, jcrlockIsDeep, jcrLockOwner, jcrMergeFailed, jcrMixinTypes, jcrPredecessors, jcrPrimaryType, jcrRootVersion, jcrSuccessors, jcrSystem, jcrUUID, jcrVersionHistory, mixLockable, mixReferenceable, mixShareable, mixSimpleVersionable, mixTitle, mixVersionable, nodeName1, nodeName2, nodeName3, nodeName4, NS_JCR_URI, NS_MIX_URI, NS_NT_URI, NS_SV_URI, ntActivity, ntBase, ntFrozenNode, ntQuery, ntUnstructured, ntVersion, ntVersionHistory, ntVersionLabels, propertyName1, propertyName2, superuser, testNodeType, testNodeTypeNoChildren, testNodeTypeTestRoot, testPath, testRoot, testRootNode, vf, workspaceName
-
-
Constructor Summary
Constructors Constructor Description AbstractObservationTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddEventListener(EventListener listener)Registers anEventListenerfor all events.protected voidaddEventListener(EventListener listener, int eventType)Registers anEventListenerfor events of the specified type(s).protected voidcheckNodeAdded(Event[] events, String[] requiredRelPaths, String[] optionalRelPaths)ChecksEventsfor paths.protected voidcheckNodeRemoved(Event[] events, String[] requiredRelPaths, String[] optionalRelPaths)ChecksEventsfor paths.protected voidcheckNodes(Event[] events, String[] requiredRelPaths, String[] optionalRelPaths, long eventType)ChecksEventsfor paths.protected voidcheckPropertyAdded(Event[] events, String[] relPaths)ChecksEventsfor paths.protected voidcheckPropertyChanged(Event[] events, String[] relPaths)ChecksEventsfor paths.protected voidcheckPropertyRemoved(Event[] events, String[] relPaths)ChecksEventsfor paths.protected EventgetEventByPath(Event[] events, String path)Returns the first event with the givenpath.protected Event[]getEvents(AbstractObservationTest.Callable call, int eventTypes)Registers an event listener for the passedeventTypesand calls the callable.protected voidremoveEventListener(EventListener listener)Removes theEventListenerfrom the ObservationManager.protected voidsetUp()protected voidtearDown()protected EventListener[]toArray(EventListenerIterator it)Consumes theEventListenerIteratorand returns theEventListeneras an array.-
Methods inherited from class org.apache.jackrabbit.test.AbstractJCRTest
checkSupportedOption, cleanUp, cleanUpTestRoot, createRandomString, ensureCanSetProperty, ensureCanSetProperty, ensureCanSetProperty, ensureKnowsNodeType, ensureLockingSupported, ensureMixinType, ensureMultipleWorkspacesSupported, getHelper, getJcrValue, getLocalName, getNonExistingWorkspaceName, getPrefix, getProperty, getProperty, getQualifiedName, getSize, isSupported, needsMixin, run
-
Methods inherited from class junit.framework.TestCase
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, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, runBare, runTest, setName, toString
-
-
-
-
Field Detail
-
DEFAULT_WAIT_TIMEOUT
protected static final long DEFAULT_WAIT_TIMEOUT
Default wait timeout for events: 5000 ms- See Also:
- Constant Field Values
-
ALL_TYPES
protected static final int ALL_TYPES
- See Also:
- Constant Field Values
-
obsMgr
protected ObservationManager obsMgr
TheObservationManager
-
-
Method Detail
-
setUp
protected void setUp() throws Exception- Overrides:
setUpin classAbstractJCRTest- Throws:
Exception
-
tearDown
protected void tearDown() throws Exception- Overrides:
tearDownin classAbstractJCRTest- Throws:
Exception
-
addEventListener
protected void addEventListener(EventListener listener) throws RepositoryException
Registers anEventListenerfor all events.- Parameters:
listener- theEventListener.- Throws:
RepositoryException- if registration fails.
-
addEventListener
protected void addEventListener(EventListener listener, int eventType) throws RepositoryException
Registers anEventListenerfor events of the specified type(s).- Parameters:
listener- theEventListener.eventType- the event types- Throws:
RepositoryException- if registration fails.
-
removeEventListener
protected void removeEventListener(EventListener listener) throws RepositoryException
Removes theEventListenerfrom the ObservationManager.- Parameters:
listener- theEventListenerto unregister.- Throws:
RepositoryException- if unregister fails.
-
toArray
protected EventListener[] toArray(EventListenerIterator it)
Consumes theEventListenerIteratorand returns theEventListeneras an array.- Parameters:
it- the iterator.- Returns:
- array of
EventListeners.
-
checkNodeAdded
protected void checkNodeAdded(Event[] events, String[] requiredRelPaths, String[] optionalRelPaths) throws RepositoryException
- Parameters:
events- theEvents.requiredRelPaths- paths to child nodes added relative toAbstractJCRTest.testRoot(required events).optionalRelPaths- paths to child nodes added relative toAbstractJCRTest.testRoot(optional events).- Throws:
RepositoryException- if an error occurs while retrieving the nodes from event instances.
-
checkNodeRemoved
protected void checkNodeRemoved(Event[] events, String[] requiredRelPaths, String[] optionalRelPaths) throws RepositoryException
- Parameters:
events- theEvents.requiredRelPaths- paths to child nodes added relative toAbstractJCRTest.testRoot(required events).optionalRelPaths- paths to child nodes added relative toAbstractJCRTest.testRoot(optional events).- Throws:
RepositoryException- if an error occurs while retrieving the nodes from event instances.
-
checkPropertyAdded
protected void checkPropertyAdded(Event[] events, String[] relPaths) throws RepositoryException
- Parameters:
events- theEvents.relPaths- paths to added properties relative toAbstractJCRTest.testRoot.- Throws:
RepositoryException- if an error occurs while retrieving the nodes from event instances.
-
checkPropertyChanged
protected void checkPropertyChanged(Event[] events, String[] relPaths) throws RepositoryException
- Parameters:
events- theEvents.relPaths- paths to changed properties relative toAbstractJCRTest.testRoot.- Throws:
RepositoryException- if an error occurs while retrieving the nodes from event instances.
-
checkPropertyRemoved
protected void checkPropertyRemoved(Event[] events, String[] relPaths) throws RepositoryException
- Parameters:
events- theEvents.relPaths- paths to removed properties relative toAbstractJCRTest.testRoot.- Throws:
RepositoryException- if an error occurs while retrieving the nodes from event instances.
-
checkNodes
protected void checkNodes(Event[] events, String[] requiredRelPaths, String[] optionalRelPaths, long eventType) throws RepositoryException
- Parameters:
events- theEvents.requiredRelPaths- paths to required item events relative toAbstractJCRTest.testRoot.optionalRelPaths- paths to optional item events relative toAbstractJCRTest.testRoot.eventType- the type of event to check.- Throws:
RepositoryException- if an error occurs while retrieving the nodes from event instances.
-
getEvents
protected Event[] getEvents(AbstractObservationTest.Callable call, int eventTypes) throws RepositoryException
Registers an event listener for the passedeventTypesand calls the callable.- Parameters:
call- the callable.eventTypes- the types of the events to listen for.- Returns:
- the events that were generated during execution of the callable.
- Throws:
RepositoryException- if an error occurs.
-
getEventByPath
protected Event getEventByPath(Event[] events, String path) throws RepositoryException
Returns the first event with the givenpath.- Parameters:
events- the events.path- the path.- Returns:
- the event with the given
pathorTestCase.fail()s if no such event exists. - Throws:
RepositoryException- if an error occurs while reading from the repository.
-
-