Source Code Cross Referenced for QueueTransmissionManager.java in  » Testing » mockrunner-0.4 » com » mockrunner » jms » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » mockrunner 0.4 » com.mockrunner.jms 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.mockrunner.jms;
002:
003:        import java.util.ArrayList;
004:        import java.util.Collections;
005:        import java.util.List;
006:
007:        import javax.jms.JMSException;
008:        import javax.jms.QueueBrowser;
009:        import javax.jms.QueueReceiver;
010:        import javax.jms.QueueSender;
011:
012:        import com.mockrunner.mock.jms.MockConnection;
013:        import com.mockrunner.mock.jms.MockQueue;
014:        import com.mockrunner.mock.jms.MockQueueBrowser;
015:        import com.mockrunner.mock.jms.MockQueueReceiver;
016:        import com.mockrunner.mock.jms.MockQueueSender;
017:        import com.mockrunner.mock.jms.MockSession;
018:
019:        /**
020:         * This class is used to create queue senders and receivers.
021:         * It can be also used to access all created classes in tests.
022:         */
023:        public class QueueTransmissionManager {
024:            private MockConnection connection;
025:            private MockSession session;
026:            private List queueSenderList;
027:            private List queueReceiverList;
028:            private List queueBrowserList;
029:
030:            public QueueTransmissionManager(MockConnection connection,
031:                    MockSession session) {
032:                this .connection = connection;
033:                this .session = session;
034:                queueSenderList = new ArrayList();
035:                queueReceiverList = new ArrayList();
036:                queueBrowserList = new ArrayList();
037:            }
038:
039:            /**
040:             * Closes all senders, receivers, browsers, publishers and subscribers.
041:             */
042:            public void closeAll() {
043:                closeAllQueueSenders();
044:                closeAllQueueReceivers();
045:                closeAllQueueBrowsers();
046:            }
047:
048:            /**
049:             * Closes all queue senders.
050:             */
051:            public void closeAllQueueSenders() {
052:                for (int ii = 0; ii < queueSenderList.size(); ii++) {
053:                    QueueSender sender = (QueueSender) queueSenderList.get(ii);
054:                    try {
055:                        sender.close();
056:                    } catch (JMSException exc) {
057:
058:                    }
059:                }
060:            }
061:
062:            /**
063:             * Closes all queue receivers.
064:             */
065:            public void closeAllQueueReceivers() {
066:                for (int ii = 0; ii < queueReceiverList.size(); ii++) {
067:                    QueueReceiver receiver = (QueueReceiver) queueReceiverList
068:                            .get(ii);
069:                    try {
070:                        receiver.close();
071:                    } catch (JMSException exc) {
072:
073:                    }
074:                }
075:            }
076:
077:            /**
078:             * Closes all queue browsers.
079:             */
080:            public void closeAllQueueBrowsers() {
081:                for (int ii = 0; ii < queueBrowserList.size(); ii++) {
082:                    QueueBrowser browser = (QueueBrowser) queueBrowserList
083:                            .get(ii);
084:                    try {
085:                        browser.close();
086:                    } catch (JMSException exc) {
087:
088:                    }
089:                }
090:            }
091:
092:            /**
093:             * Creates a new <code>QueueSender</code> for the specified
094:             * <code>Queue</code>. Usually this method is called
095:             * by {@link com.mockrunner.mock.jms.MockQueueSession#createSender}.
096:             * @param queue the <code>Queue</code>
097:             * @return the created <code>QueueSender</code>
098:             */
099:            public MockQueueSender createQueueSender(MockQueue queue) {
100:                MockQueueSender sender = new MockQueueSender(connection,
101:                        session, queue);
102:                queueSenderList.add(sender);
103:                return sender;
104:            }
105:
106:            /**
107:             * Returns a <code>QueueSender</code> by its index or
108:             * <code>null</code>, if no such <code>QueueSender</code> is
109:             * present.
110:             * @param index the index of the <code>QueueSender</code>
111:             * @return the <code>QueueSender</code>
112:             */
113:            public MockQueueSender getQueueSender(int index) {
114:                if (queueSenderList.size() <= index || index < 0)
115:                    return null;
116:                return (MockQueueSender) queueSenderList.get(index);
117:            }
118:
119:            /**
120:             * Returns a <code>QueueSender</code> by the name of its
121:             * corresponding <code>Queue</code>. If there's more than
122:             * one <code>QueueSender</code> object for the specified name,
123:             * the first one will be returned.
124:             * @param queueName the name of the <code>Queue</code>
125:             * @return the <code>QueueSender</code>
126:             */
127:            public MockQueueSender getQueueSender(String queueName) {
128:                List senders = getQueueSenderList(queueName);
129:                if (senders.size() <= 0)
130:                    return null;
131:                return (MockQueueSender) senders.get(0);
132:            }
133:
134:            /**
135:             * Returns the list of the <code>QueueSender</code> objects
136:             * for a specific <code>Queue</code>.
137:             * @param queueName the name of the <code>Queue</code>
138:             * @return the list of <code>QueueSender</code> objects
139:             */
140:            public List getQueueSenderList(String queueName) {
141:                List resultList = new ArrayList();
142:                for (int ii = 0; ii < queueSenderList.size(); ii++) {
143:                    QueueSender sender = (QueueSender) queueSenderList.get(ii);
144:                    try {
145:                        if (sender.getQueue().getQueueName().equals(queueName)) {
146:                            resultList.add(sender);
147:                        }
148:                    } catch (JMSException exc) {
149:
150:                    }
151:                }
152:                return Collections.unmodifiableList(resultList);
153:            }
154:
155:            /**
156:             * Returns the list of all <code>QueueSender</code> objects.
157:             * @return the list of <code>QueueSender</code> objects
158:             */
159:            public List getQueueSenderList() {
160:                return Collections.unmodifiableList(queueSenderList);
161:            }
162:
163:            /**
164:             * Creates a new <code>QueueReceiver</code> for the specified
165:             * <code>Queue</code>. Usually this method is called
166:             * by {@link com.mockrunner.mock.jms.MockQueueSession#createReceiver}.
167:             * @param queue the <code>Queue</code>
168:             * @param messageSelector the message selector
169:             * @return the created <code>QueueReceiver</code>
170:             */
171:            public MockQueueReceiver createQueueReceiver(MockQueue queue,
172:                    String messageSelector) {
173:                MockQueueReceiver receiver = new MockQueueReceiver(connection,
174:                        session, queue, messageSelector);
175:                queueReceiverList.add(receiver);
176:                return receiver;
177:            }
178:
179:            /**
180:             * Returns a <code>QueueReceiver</code> by its index or
181:             * <code>null</code>, if no such <code>QueueReceiver</code> is
182:             * present.
183:             * @param index the index of the <code>QueueReceiver</code>
184:             * @return the <code>QueueReceiver</code>
185:             */
186:            public MockQueueReceiver getQueueReceiver(int index) {
187:                if (queueReceiverList.size() <= index || index < 0)
188:                    return null;
189:                return (MockQueueReceiver) queueReceiverList.get(index);
190:            }
191:
192:            /**
193:             * Returns a <code>QueueReceiver</code> by the name of its
194:             * corresponding <code>Queue</code>. If there's more than
195:             * one <code>QueueReceiver</code> object for the specified name,
196:             * the first one will be returned.
197:             * @param queueName the name of the <code>Queue</code>
198:             * @return the <code>QueueReceiver</code>
199:             */
200:            public MockQueueReceiver getQueueReceiver(String queueName) {
201:                List receivers = getQueueReceiverList(queueName);
202:                if (receivers.size() <= 0)
203:                    return null;
204:                return (MockQueueReceiver) receivers.get(0);
205:            }
206:
207:            /**
208:             * Returns the list of the <code>QueueReceiver</code> objects
209:             * for a specific <code>Queue</code>.
210:             * @param queueName the name of the <code>Queue</code>
211:             * @return the list of <code>QueueReceiver</code> objects
212:             */
213:            public List getQueueReceiverList(String queueName) {
214:                List resultList = new ArrayList();
215:                for (int ii = 0; ii < queueReceiverList.size(); ii++) {
216:                    QueueReceiver receiver = (QueueReceiver) queueReceiverList
217:                            .get(ii);
218:                    try {
219:                        if (receiver.getQueue().getQueueName()
220:                                .equals(queueName)) {
221:                            resultList.add(receiver);
222:                        }
223:                    } catch (JMSException exc) {
224:
225:                    }
226:                }
227:                return Collections.unmodifiableList(resultList);
228:            }
229:
230:            /**
231:             * Returns the list of <code>QueueReceiver</code> objects.
232:             * @return the <code>QueueReceiver</code> list
233:             */
234:            public List getQueueReceiverList() {
235:                return Collections.unmodifiableList(queueReceiverList);
236:            }
237:
238:            /**
239:             * Creates a new <code>QueueBrowser</code> for the specified
240:             * <code>Queue</code>. Usually this method is called
241:             * by {@link com.mockrunner.mock.jms.MockQueueSession#createBrowser}.
242:             * @param queue the <code>Queue</code>
243:             * @param messageSelector the message selector
244:             * @return the created <code>QueueBrowser</code>
245:             */
246:            public MockQueueBrowser createQueueBrowser(MockQueue queue,
247:                    String messageSelector) {
248:                MockQueueBrowser browser = new MockQueueBrowser(connection,
249:                        queue, messageSelector);
250:                queueBrowserList.add(browser);
251:                return browser;
252:            }
253:
254:            /**
255:             * Returns a <code>QueueBrowser</code> by its index or
256:             * <code>null</code>, if no such <code>QueueBrowser</code> is
257:             * present.
258:             * @param index the index of the <code>QueueBrowser</code>
259:             * @return the <code>QueueBrowser</code>
260:             */
261:            public MockQueueBrowser getQueueBrowser(int index) {
262:                if (queueBrowserList.size() <= index || index < 0)
263:                    return null;
264:                return (MockQueueBrowser) queueBrowserList.get(index);
265:            }
266:
267:            /**
268:             * Returns a <code>QueueBrowser</code> by the name of its
269:             * corresponding <code>Queue</code>. If there's more than
270:             * one <code>QueueBrowser</code> object for the specified name,
271:             * the first one will be returned.
272:             * @param queueName the name of the <code>Queue</code>
273:             * @return the <code>QueueBrowser</code>
274:             */
275:            public MockQueueBrowser getQueueBrowser(String queueName) {
276:                List browsers = getQueueBrowserList(queueName);
277:                if (browsers.size() <= 0)
278:                    return null;
279:                return (MockQueueBrowser) browsers.get(0);
280:            }
281:
282:            /**
283:             * Returns the list of the <code>QueueBrowser</code> objects
284:             * for a specific <code>Queue</code>.
285:             * @param queueName the name of the <code>Queue</code>
286:             * @return the list of <code>QueueBrowser</code> objects
287:             */
288:            public List getQueueBrowserList(String queueName) {
289:                List resultList = new ArrayList();
290:                for (int ii = 0; ii < queueBrowserList.size(); ii++) {
291:                    QueueBrowser browser = (QueueBrowser) queueBrowserList
292:                            .get(ii);
293:                    try {
294:                        if (browser.getQueue().getQueueName().equals(queueName)) {
295:                            resultList.add(browser);
296:                        }
297:                    } catch (JMSException exc) {
298:
299:                    }
300:                }
301:                return Collections.unmodifiableList(resultList);
302:            }
303:
304:            /**
305:             * Returns the list of <code>QueueBrowser</code> objects.
306:             * @return the <code>QueueBrowser</code> list
307:             */
308:            public List getQueueBrowserList() {
309:                return Collections.unmodifiableList(queueBrowserList);
310:            }
311:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.