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 interface
AbstractObservationTest.Callable
Helper interface.
-
Field Summary
Fields Modifier and Type Field Description protected static int
ALL_TYPES
protected static long
DEFAULT_WAIT_TIMEOUT
Default wait timeout for events: 5000 msprotected ObservationManager
obsMgr
TheObservationManager
-
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 void
addEventListener(EventListener listener)
Registers anEventListener
for all events.protected void
addEventListener(EventListener listener, int eventType)
Registers anEventListener
for events of the specified type(s).protected void
checkNodeAdded(Event[] events, String[] requiredRelPaths, String[] optionalRelPaths)
ChecksEvents
for paths.protected void
checkNodeRemoved(Event[] events, String[] requiredRelPaths, String[] optionalRelPaths)
ChecksEvents
for paths.protected void
checkNodes(Event[] events, String[] requiredRelPaths, String[] optionalRelPaths, long eventType)
ChecksEvents
for paths.protected void
checkPropertyAdded(Event[] events, String[] relPaths)
ChecksEvents
for paths.protected void
checkPropertyChanged(Event[] events, String[] relPaths)
ChecksEvents
for paths.protected void
checkPropertyRemoved(Event[] events, String[] relPaths)
ChecksEvents
for paths.protected Event
getEventByPath(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 passedeventTypes
and calls the callable.protected void
removeEventListener(EventListener listener)
Removes theEventListener
from the ObservationManager.protected void
setUp()
protected void
tearDown()
protected EventListener[]
toArray(EventListenerIterator it)
Consumes theEventListenerIterator
and returns theEventListener
as 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:
setUp
in classAbstractJCRTest
- Throws:
Exception
-
tearDown
protected void tearDown() throws Exception
- Overrides:
tearDown
in classAbstractJCRTest
- Throws:
Exception
-
addEventListener
protected void addEventListener(EventListener listener) throws RepositoryException
Registers anEventListener
for all events.- Parameters:
listener
- theEventListener
.- Throws:
RepositoryException
- if registration fails.
-
addEventListener
protected void addEventListener(EventListener listener, int eventType) throws RepositoryException
Registers anEventListener
for 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 theEventListener
from the ObservationManager.- Parameters:
listener
- theEventListener
to unregister.- Throws:
RepositoryException
- if unregister fails.
-
toArray
protected EventListener[] toArray(EventListenerIterator it)
Consumes theEventListenerIterator
and returns theEventListener
as an array.- Parameters:
it
- the iterator.- Returns:
- array of
EventListeners
.
-
checkNodeAdded
protected void checkNodeAdded(Event[] events, String[] requiredRelPaths, String[] optionalRelPaths) throws RepositoryException
- Parameters:
events
- theEvent
s.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
- theEvent
s.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
- theEvent
s.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
- theEvent
s.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
- theEvent
s.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
- theEvent
s.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 passedeventTypes
and 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
path
orTestCase.fail()
s if no such event exists. - Throws:
RepositoryException
- if an error occurs while reading from the repository.
-
-