mondrian.rolap.agg
Class MockSegmentCache

java.lang.Object
  extended by mondrian.rolap.agg.MockSegmentCache
All Implemented Interfaces:
SegmentCache

public class MockSegmentCache
extends Object
implements SegmentCache

Mock implementation of SegmentCache that is used for automated testing.

It tries to marshall / unmarshall all SegmentHeader and SegmentBody objects that are sent to it.

Author:
LBoudreau

Nested Class Summary
 
Nested classes/interfaces inherited from interface mondrian.spi.SegmentCache
SegmentCache.SegmentCacheInjector, SegmentCache.SegmentCacheListener
 
Constructor Summary
MockSegmentCache()
           
 
Method Summary
 void addListener(SegmentCache.SegmentCacheListener listener)
          Adds a listener to this segment cache implementation.
 boolean contains(SegmentHeader header)
           
 void fireSegmentCacheEvent(SegmentCache.SegmentCacheListener.SegmentCacheEvent event)
           
 SegmentBody get(SegmentHeader header)
          Returns a SegmentBody once the cache has returned any results, or null if no segment corresponding to the header could be found.
 List<SegmentHeader> getSegmentHeaders()
          Returns a list of all segments present in the cache.
 boolean put(SegmentHeader header, SegmentBody body)
          Stores a segment data in the cache.
 boolean remove(SegmentHeader header)
          Removes a segment from the cache.
 void removeListener(SegmentCache.SegmentCacheListener listener)
          Unregisters a listener from this segment cache implementation.
 boolean supportsRichIndex()
          Tells Mondrian whether this segment cache uses the SegmentHeader objects as an index, thus preserving them in a serialized state, or if it uses its identification number only.
 void tearDown()
          Tear down and clean up the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockSegmentCache

public MockSegmentCache()
Method Detail

contains

public boolean contains(SegmentHeader header)

get

public SegmentBody get(SegmentHeader header)
Description copied from interface: SegmentCache
Returns a SegmentBody once the cache has returned any results, or null if no segment corresponding to the header could be found.

Cache implementations are at liberty to 'forget' segments. Therefore it is allowable for this method to return null at any time

Specified by:
get in interface SegmentCache
Parameters:
header - The header of the segment to find. Consider this as a key.
Returns:
A SegmentBody, or null if no corresponding segment could be found in cache.

put

public boolean put(SegmentHeader header,
                   SegmentBody body)
Description copied from interface: SegmentCache
Stores a segment data in the cache.

Specified by:
put in interface SegmentCache
Parameters:
header - The header of the segment.
body - The segment body to cache.
Returns:
Whether the cache write succeeded

getSegmentHeaders

public List<SegmentHeader> getSegmentHeaders()
Description copied from interface: SegmentCache
Returns a list of all segments present in the cache.

Specified by:
getSegmentHeaders in interface SegmentCache
Returns:
A List of segment headers describing the contents of the cache.

remove

public boolean remove(SegmentHeader header)
Description copied from interface: SegmentCache
Removes a segment from the cache.

Specified by:
remove in interface SegmentCache
Parameters:
header - The header of the segment we want to remove.
Returns:
True if the segment was found and removed, false otherwise.

tearDown

public void tearDown()
Description copied from interface: SegmentCache
Tear down and clean up the cache.

Specified by:
tearDown in interface SegmentCache

addListener

public void addListener(SegmentCache.SegmentCacheListener listener)
Description copied from interface: SegmentCache
Adds a listener to this segment cache implementation. The listener will get notified via SegmentCache.SegmentCacheListener.SegmentCacheEvent instances.

Specified by:
addListener in interface SegmentCache
Parameters:
listener - The listener to attach to this cache.

removeListener

public void removeListener(SegmentCache.SegmentCacheListener listener)
Description copied from interface: SegmentCache
Unregisters a listener from this segment cache implementation.

Specified by:
removeListener in interface SegmentCache
Parameters:
listener - The listener to remove.

supportsRichIndex

public boolean supportsRichIndex()
Description copied from interface: SegmentCache
Tells Mondrian whether this segment cache uses the SegmentHeader objects as an index, thus preserving them in a serialized state, or if it uses its identification number only.

Not using a rich index prevents Mondrian from doing partial cache invalidation.

It is assumed that this method returns fairly quickly, and for a given cache always returns the same value.

Specified by:
supportsRichIndex in interface SegmentCache
Returns:
Whether this segment cache preserves headers in serialized state

fireSegmentCacheEvent

public void fireSegmentCacheEvent(SegmentCache.SegmentCacheListener.SegmentCacheEvent event)

Get Mondrian at SourceForge.net. Fast, secure and free Open Source software downloads