01: /* Copyright 2004 The JA-SIG Collaborative. All rights reserved.
02: * See license distributed with this file and
03: * available online at http://www.uportal.org/license.html
04: */
05:
06: package org.jasig.portal.channels;
07:
08: import java.util.ArrayList;
09: import java.util.List;
10:
11: import org.jasig.portal.ChannelRuntimeData;
12: import org.jasig.portal.ChannelRuntimeProperties;
13: import org.jasig.portal.ChannelStaticData;
14: import org.jasig.portal.IChannel;
15: import org.jasig.portal.PortalEvent;
16: import org.jasig.portal.PortalException;
17: import org.xml.sax.ContentHandler;
18:
19: /**
20: * Mock channel implementation which exists to record
21: * the events it receives. Useful for testcases.
22: * @author andrew.petro@yale.edu
23: */
24: public class EventRecordingChannel implements IChannel {
25:
26: private List eventsReceived = new ArrayList();
27:
28: /* (non-Javadoc)
29: * @see org.jasig.portal.IChannel#setStaticData(org.jasig.portal.ChannelStaticData)
30: */
31: public void setStaticData(ChannelStaticData sd)
32: throws PortalException {
33: // does nothing - mock implementation
34: }
35:
36: /* (non-Javadoc)
37: * @see org.jasig.portal.IChannel#setRuntimeData(org.jasig.portal.ChannelRuntimeData)
38: */
39: public void setRuntimeData(ChannelRuntimeData rd)
40: throws PortalException {
41: // does nothing - mock implementation
42: }
43:
44: /* (non-Javadoc)
45: * @see org.jasig.portal.IChannel#receiveEvent(org.jasig.portal.PortalEvent)
46: */
47: public void receiveEvent(PortalEvent ev) {
48: // record the event -- my reason for being!
49: this .eventsReceived.add(ev);
50: }
51:
52: /* (non-Javadoc)
53: * @see org.jasig.portal.IChannel#getRuntimeProperties()
54: */
55: public ChannelRuntimeProperties getRuntimeProperties() {
56: // mock implementation
57: return new ChannelRuntimeProperties();
58: }
59:
60: /* (non-Javadoc)
61: * @see org.jasig.portal.IChannel#renderXML(org.xml.sax.ContentHandler)
62: */
63: public void renderXML(ContentHandler out) throws PortalException {
64: // do nothing - mock implementation
65: }
66:
67: /**
68: * Get a List of events received by this channel in the order they were
69: * received.
70: * @return Returns the eventsReceived.
71: */
72: public List getEventsReceived() {
73: return eventsReceived;
74: }
75:
76: }
|