001: /*
002: * MessageService: The message service daemon
003: * Copyright (C) 2006 Rift IT Contracting
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2.1 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
018: *
019: * MessageManagerImplTest.java
020: */
021:
022: // package path
023: package com.rift.coad.daemon.messageservice.message;
024:
025: // java imports
026: import javax.naming.InitialContext;
027: import javax.naming.Context;
028: import java.sql.PreparedStatement;
029: import java.sql.ResultSet;
030: import java.sql.Statement;
031: import javax.sql.DataSource;
032: import java.util.Set;
033: import java.util.HashSet;
034: import javax.transaction.UserTransaction;
035: import java.sql.Timestamp;
036: import java.util.ArrayList;
037: import java.util.Date;
038: import java.util.Enumeration;
039: import java.util.HashSet;
040: import java.util.Iterator;
041: import java.util.List;
042: import java.util.Set;
043: import javax.transaction.xa.XAException;
044: import javax.transaction.xa.XAResource;
045: import javax.transaction.xa.Xid;
046: import org.hibernate.*;
047: import org.hibernate.cfg.*;
048: import org.apache.log4j.Logger;
049: import org.apache.log4j.BasicConfigurator;
050:
051: // junit imports
052: import junit.framework.*;
053:
054: // object web imports
055: import org.objectweb.jotm.Jotm;
056:
057: // coadunation imports
058: import com.rift.coad.lib.naming.NamingDirector;
059: import com.rift.coad.lib.naming.ContextManager;
060: import com.rift.coad.lib.db.DBSourceManager;
061: import com.rift.coad.lib.common.ObjectSerializer;
062: import com.rift.coad.lib.interceptor.InterceptorFactory;
063: import com.rift.coad.lib.security.RoleManager;
064: import com.rift.coad.lib.security.ThreadsPermissionContainer;
065: import com.rift.coad.lib.security.ThreadPermissionSession;
066: import com.rift.coad.lib.security.UserSession;
067: import com.rift.coad.lib.security.user.UserSessionManager;
068: import com.rift.coad.lib.security.user.UserStoreManager;
069: import com.rift.coad.lib.security.SessionManager;
070: import com.rift.coad.lib.security.login.LoginManager;
071: import com.rift.coad.lib.thread.CoadunationThreadGroup;
072: import com.rift.coad.lib.transaction.TransactionDirector;
073: import com.rift.coad.daemon.messageservice.Message;
074: import com.rift.coad.daemon.messageservice.MessageError;
075: import com.rift.coad.daemon.messageservice.RPCMessage;
076: import com.rift.coad.daemon.messageservice.TextMessage;
077: import com.rift.coad.daemon.messageservice.MessageManager;
078: import com.rift.coad.daemon.messageservice.MessageServiceException;
079: import com.rift.coad.daemon.messageservice.MessageServiceManager;
080: import com.rift.coad.daemon.messageservice.db.*;
081: import com.rift.coad.daemon.messageservice.message.MessageImpl;
082: import com.rift.coad.daemon.messageservice.message.RPCMessageImpl;
083: import com.rift.coad.daemon.messageservice.message.TextMessageImpl;
084: import com.rift.coad.hibernate.util.HibernateUtil;
085: import com.rift.coad.util.lock.ObjectLockFactory;
086: import com.rift.coad.util.transaction.TransactionManager;
087: import com.rift.coad.util.change.ChangeLog;
088: import com.rift.coad.lib.thread.ThreadGroupManager;
089:
090: /**
091: * The test of the message manager
092: *
093: * @author Brett Chaldecott
094: */
095: public class MessageManagerImplTest extends TestCase {
096:
097: public MessageManagerImplTest(String testName) {
098: super (testName);
099: //BasicConfigurator.configure();
100: }
101:
102: protected void setUp() throws Exception {
103: }
104:
105: protected void tearDown() throws Exception {
106: }
107:
108: /**
109: * Test of com.rift.coad.daemon.messageservice.message.MessageManagerImpl.
110: */
111: public void testMessageManagerImpl() throws Exception {
112: System.out.println("testMessageManagerImpl");
113:
114: Thread.currentThread().setContextClassLoader(
115: this .getClass().getClassLoader());
116:
117: // init the session information
118: ThreadsPermissionContainer permissions = new ThreadsPermissionContainer();
119: SessionManager.init(permissions);
120: UserStoreManager userStoreManager = new UserStoreManager();
121: UserSessionManager sessionManager = new UserSessionManager(
122: permissions, userStoreManager);
123: LoginManager.init(sessionManager, userStoreManager);
124: // instanciate the thread manager
125: CoadunationThreadGroup threadGroup = new CoadunationThreadGroup(
126: sessionManager, userStoreManager);
127:
128: // add a user to the session for the current thread
129: RoleManager.getInstance();
130:
131: InterceptorFactory.init(permissions, sessionManager,
132: userStoreManager);
133:
134: // add a new user object and add to the permission
135: Set set = new HashSet();
136: set.add("test");
137: UserSession user = new UserSession("test1", set);
138: permissions.putSession(
139: new Long(Thread.currentThread().getId()),
140: new ThreadPermissionSession(new Long(Thread
141: .currentThread().getId()), user));
142:
143: // instanciate the thread manager
144: ThreadGroupManager.getInstance().initThreadGroup(threadGroup);
145:
146: // init the naming director
147: NamingDirector.init(threadGroup);
148:
149: // instanciate the transaction director
150: TransactionDirector transactionDirector = TransactionDirector
151: .init();
152:
153: // init the database source
154: DBSourceManager.init();
155: ObjectLockFactory.init();
156: TransactionManager.init();
157: ChangeLog.init(MessageServiceManager.class);
158: ChangeLog.getInstance().start();
159: Context context = new InitialContext();
160:
161: List principals = new ArrayList(set);
162: Date currentTime = new Date();
163: TextMessageImpl textMessage = new TextMessageImpl("test",
164: "test", "test", principals, Message.UNDELIVERED);
165: textMessage.setFrom("test");
166: textMessage.setTextBody("test text");
167: textMessage.setStringProperty("TESTString", "TESTvalue");
168: textMessage.setBooleanProperty("TESTBoolean", true);
169: textMessage.setByteProperty("TESTByte", (byte) 1);
170: textMessage.setCorrelationId("TESTCorrelationId");
171: textMessage.setDoubleProperty("TESTDouble", 1.1);
172: textMessage.setFloatProperty("TESTFloat", (float) 2.2);
173: textMessage.setFrom("test@test.com");
174: textMessage.setIntProperty("TESTInt", 100);
175: textMessage.setLongProperty("TESTLong", (long) 2000);
176: textMessage.setTargetNamedQueue("QUEUEName");
177: textMessage.setReplyNamedQueue("ReplyQUEUEName");
178: textMessage.setNextProcessDate(currentTime);
179: textMessage.setObjectProperty("TESTObject",
180: "This is a test obj");
181: textMessage.setPriority(1000);
182: textMessage.setProcessedDate(currentTime);
183: textMessage.setReply(true);
184: textMessage.setServices(new String[] { "test1", "test2",
185: "test3" });
186: textMessage.setTarget("target");
187: textMessage.addError(1, "test error1");
188: textMessage.addError(2, "test error2");
189: UserTransaction ut = (UserTransaction) context
190: .lookup("java:comp/UserTransaction");
191:
192: ut.begin();
193:
194: MessageManagerImpl instance = new MessageManagerImpl(
195: textMessage);
196:
197: ut.commit();
198:
199: String expResult = "test";
200: String result = instance.getID();
201: assertEquals(expResult, result);
202:
203: ut.begin();
204: Message retrievedMessage = instance.getMessage();
205: ut.commit();
206: Date nextProcessTime = new Date(currentTime.getTime() + 1000);
207:
208: assertEquals(retrievedMessage.getMessageId(), "test");
209: System.out.println("["
210: + retrievedMessage.getStringProperty("TESTString")
211: + "][TESTvalue]");
212: assertEquals(retrievedMessage.getStringProperty("TESTString"),
213: "TESTvalue");
214: retrievedMessage.setStringProperty("TESTString", "TESTvalue2");
215: assertEquals(((TextMessage) retrievedMessage).getTextBody(),
216: "test text");
217: ((TextMessage) retrievedMessage)
218: .setTextBody("testing text again");
219: assertEquals(
220: retrievedMessage.getBooleanProperty("TESTBoolean"),
221: true);
222: retrievedMessage.setBooleanProperty("TESTBoolean", false);
223: assertEquals(retrievedMessage.getByteProperty("TESTByte"),
224: (byte) 1);
225: retrievedMessage.setByteProperty("TESTByte", (byte) 2);
226: assertEquals(retrievedMessage.getCorrelationId(),
227: "TESTCorrelationId");
228: retrievedMessage.setCorrelationId("TESTCorrelationId2");
229: assertEquals(retrievedMessage.getDoubleProperty("TESTDouble"),
230: (double) 1.1);
231: retrievedMessage.setDoubleProperty("TESTDouble", 2.5);
232: assertEquals(retrievedMessage.getFloatProperty("TESTFloat"),
233: (float) 2.2);
234: retrievedMessage.setFloatProperty("TESTFloat", (float) 4.4);
235: assertEquals(retrievedMessage.getFrom(), "test@test.com");
236: assertEquals(retrievedMessage.getIntProperty("TESTInt"), 100);
237: retrievedMessage.setIntProperty("TESTInt", 200);
238: assertEquals(retrievedMessage.getLongProperty("TESTLong"),
239: (long) 2000);
240: retrievedMessage.setLongProperty("TESTLong", (long) 4000);
241: assertEquals(retrievedMessage.getTargetNamedQueue(),
242: "QUEUEName");
243: assertEquals(retrievedMessage.getReplyNamedQueue(),
244: "ReplyQUEUEName");
245: assertEquals(((MessageImpl) retrievedMessage)
246: .getNextProcessDate().getTime() / 1000, currentTime
247: .getTime() / 1000);
248: ((MessageImpl) retrievedMessage)
249: .setNextProcessDate(nextProcessTime);
250: assertEquals(retrievedMessage.getObjectProperty("TESTObject"),
251: "This is a test obj");
252: retrievedMessage.setObjectProperty("TESTObject",
253: "this is a new object value");
254: assertEquals(retrievedMessage.getPriority(), 1000);
255: retrievedMessage.setPriority(2000);
256: assertEquals(
257: retrievedMessage.getProcessedDate().getTime() / 1000,
258: currentTime.getTime() / 1000);
259: retrievedMessage.setProcessedDate(nextProcessTime);
260: assertEquals(retrievedMessage.getReply(), true);
261: assertEquals(retrievedMessage.getState(), Message.UNDELIVERED);
262: String[] services = retrievedMessage.getServices();
263: int foundCount = 0;
264: for (int index = 0; index < 3; index++) {
265: if (services[index].equals("test1")
266: || services[index].equals("test2")
267: || services[index].equals("test3")) {
268: foundCount++;
269: }
270: }
271: assertEquals(foundCount, 3);
272: assertEquals(retrievedMessage.getTarget(), "target");
273: assertEquals(retrievedMessage.getMessageCreater(), "test");
274: List retrievedPrincipals = retrievedMessage
275: .getMessagePrincipals();
276: if (retrievedPrincipals.size() != 1) {
277: fail("Invalid list principals");
278: }
279: if (!principals.equals(retrievedPrincipals)) {
280: fail("The retrieved principals are not equal.");
281: }
282: List errors = retrievedMessage.getErrors();
283: if (errors.size() != 2) {
284: fail("Invalid number of errors");
285: }
286: foundCount = 0;
287: for (Iterator iter = errors.iterator(); iter.hasNext();) {
288: com.rift.coad.daemon.messageservice.MessageError error = (com.rift.coad.daemon.messageservice.MessageError) iter
289: .next();
290: if ((error.getLevel() == 1)
291: && (error.getMSG().equals("test error1"))) {
292: foundCount++;
293: } else if ((error.getLevel() == 2)
294: && (error.getMSG().equals("test error2"))) {
295: foundCount++;
296: }
297: }
298: if (foundCount != 2) {
299: fail("The errors were not stored correctly");
300: }
301: retrievedMessage.addError(3, "test error3");
302:
303: ut.begin();
304: Session session = HibernateUtil.getInstance(
305: MessageServiceManager.class).getSession();
306: MessageQueue messageQueue = new MessageQueue("test");
307: session.persist(messageQueue);
308: instance.updateMessage(retrievedMessage);
309: instance.assignToQueue("test");
310: ut.commit();
311:
312: ut.begin();
313: retrievedMessage = instance.getMessage();
314: ut.commit();
315:
316: assertEquals(retrievedMessage.getMessageId(), "test");
317: System.out.println("["
318: + retrievedMessage.getStringProperty("TESTString")
319: + "][TESTvalue2]");
320: assertEquals(retrievedMessage.getStringProperty("TESTString"),
321: "TESTvalue2");
322: assertEquals(((TextMessage) retrievedMessage).getTextBody(),
323: "testing text again");
324: assertEquals(
325: retrievedMessage.getBooleanProperty("TESTBoolean"),
326: false);
327: assertEquals(retrievedMessage.getByteProperty("TESTByte"),
328: (byte) 2);
329: assertEquals(retrievedMessage.getDoubleProperty("TESTDouble"),
330: (double) 2.5);
331: assertEquals(retrievedMessage.getFloatProperty("TESTFloat"),
332: (float) 4.4);
333: assertEquals(retrievedMessage.getFrom(), "test@test.com");
334: assertEquals(retrievedMessage.getIntProperty("TESTInt"), 200);
335: assertEquals(retrievedMessage.getLongProperty("TESTLong"),
336: (long) 4000);
337: assertEquals(retrievedMessage.getTargetNamedQueue(),
338: "QUEUEName");
339: assertEquals(retrievedMessage.getReplyNamedQueue(),
340: "ReplyQUEUEName");
341: assertEquals(((MessageImpl) retrievedMessage)
342: .getNextProcessDate().getTime() / 1000, nextProcessTime
343: .getTime() / 1000);
344: assertEquals(retrievedMessage.getObjectProperty("TESTObject"),
345: "this is a new object value");
346: assertEquals(
347: retrievedMessage.getProcessedDate().getTime() / 1000,
348: nextProcessTime.getTime() / 1000);
349: assertEquals(retrievedMessage.getReply(), true);
350: services = retrievedMessage.getServices();
351: foundCount = 0;
352: for (int index = 0; index < 3; index++) {
353: if (services[index].equals("test1")
354: || services[index].equals("test2")
355: || services[index].equals("test3")) {
356: foundCount++;
357: }
358: }
359: assertEquals(foundCount, 3);
360: assertEquals(retrievedMessage.getTarget(), "target");
361:
362: errors = retrievedMessage.getErrors();
363: if (errors.size() != 3) {
364: fail("Invalid number of errors");
365: }
366: foundCount = 0;
367: for (Iterator iter = errors.iterator(); iter.hasNext();) {
368: com.rift.coad.daemon.messageservice.MessageError error = (com.rift.coad.daemon.messageservice.MessageError) iter
369: .next();
370: if ((error.getLevel() == 1)
371: && (error.getMSG().equals("test error1"))) {
372: foundCount++;
373: } else if ((error.getLevel() == 2)
374: && (error.getMSG().equals("test error2"))) {
375: foundCount++;
376: } else if ((error.getLevel() == 3)
377: && (error.getMSG().equals("test error3"))) {
378: foundCount++;
379: }
380: }
381: if (foundCount != 3) {
382: fail("The errors were not stored correctly");
383: }
384:
385: ut.begin();
386: instance.remove();
387: ut.commit();
388:
389: currentTime = new Date();
390: RPCMessageImpl rpcMessage = new RPCMessageImpl("test", "test",
391: "test", principals, Message.UNDELIVERED);
392: rpcMessage.setFrom("test");
393: rpcMessage.setMethodBodyXML("test text");
394: rpcMessage.setStringProperty("TESTString", "TESTvalue");
395: rpcMessage.setBooleanProperty("TESTBoolean", true);
396: rpcMessage.setByteProperty("TESTByte", (byte) 1);
397: rpcMessage.setCorrelationId("TESTCorrelationId");
398: rpcMessage.setDoubleProperty("TESTDouble", 1.1);
399: rpcMessage.setFloatProperty("TESTFloat", (float) 2.2);
400: rpcMessage.setFrom("test@test.com");
401: rpcMessage.setIntProperty("TESTInt", 100);
402: rpcMessage.setLongProperty("TESTLong", (long) 2000);
403: rpcMessage.setTargetNamedQueue("QUEUEName");
404: rpcMessage.setReplyNamedQueue("ReplyQUEUEName");
405: rpcMessage.setNextProcessDate(currentTime);
406: rpcMessage
407: .setObjectProperty("TESTObject", "This is a test obj");
408: rpcMessage.setPriority(1000);
409: rpcMessage.setProcessedDate(currentTime);
410: rpcMessage.setReply(true);
411: rpcMessage
412: .setServices(new String[] { "test1", "test2", "test3" });
413: rpcMessage.setTarget("target");
414:
415: ut.begin();
416:
417: MessageManagerImpl instance2 = new MessageManagerImpl(
418: rpcMessage);
419:
420: ut.commit();
421:
422: Thread.sleep(30000);
423:
424: ut.begin();
425:
426: MessageManagerImpl instance3 = new MessageManagerImpl("test");
427:
428: ut.commit();
429:
430: ut.begin();
431: retrievedMessage = instance2.getMessage();
432: Message retrievedMessage2 = instance3.getMessage();
433: ut.commit();
434: nextProcessTime = new Date(currentTime.getTime() + 1000);
435:
436: assertEquals(retrievedMessage2.getMessageId(), "test");
437: assertEquals(retrievedMessage2.getStringProperty("TESTString"),
438: "TESTvalue");
439: assertEquals(((RPCMessage) retrievedMessage2)
440: .getMethodBodyXML(), "test text");
441: assertEquals(retrievedMessage2
442: .getBooleanProperty("TESTBoolean"), true);
443: assertEquals(retrievedMessage2.getByteProperty("TESTByte"),
444: (byte) 1);
445: assertEquals(retrievedMessage2.getCorrelationId(),
446: "TESTCorrelationId");
447: assertEquals(retrievedMessage2.getDoubleProperty("TESTDouble"),
448: (double) 1.1);
449: assertEquals(retrievedMessage2.getFloatProperty("TESTFloat"),
450: (float) 2.2);
451: assertEquals(retrievedMessage2.getFrom(), "test@test.com");
452: assertEquals(retrievedMessage2.getIntProperty("TESTInt"), 100);
453: assertEquals(retrievedMessage2.getLongProperty("TESTLong"),
454: (long) 2000);
455: assertEquals(retrievedMessage2.getTargetNamedQueue(),
456: "QUEUEName");
457: assertEquals(retrievedMessage2.getReplyNamedQueue(),
458: "ReplyQUEUEName");
459: assertEquals(((MessageImpl) retrievedMessage2)
460: .getNextProcessDate().getTime() / 1000, currentTime
461: .getTime() / 1000);
462: assertEquals(retrievedMessage2.getObjectProperty("TESTObject"),
463: "This is a test obj");
464: assertEquals(retrievedMessage2.getPriority(), 1000);
465: assertEquals(
466: retrievedMessage2.getProcessedDate().getTime() / 1000,
467: currentTime.getTime() / 1000);
468: assertEquals(retrievedMessage2.getReply(), true);
469: services = retrievedMessage2.getServices();
470: foundCount = 0;
471: for (int index = 0; index < 3; index++) {
472: if (services[index].equals("test1")
473: || services[index].equals("test2")
474: || services[index].equals("test3")) {
475: foundCount++;
476: }
477: }
478: assertEquals(foundCount, 3);
479: assertEquals(retrievedMessage2.getTarget(), "target");
480: assertEquals(retrievedMessage2.getMessageCreater(), "test");
481: retrievedPrincipals = retrievedMessage2.getMessagePrincipals();
482: if (retrievedPrincipals.size() != 1) {
483: fail("Invalid list principals");
484: }
485: if (!principals.equals(retrievedPrincipals)) {
486: fail("The retrieved principals are not equal.");
487: }
488:
489: assertEquals(retrievedMessage.getMessageId(), "test");
490: System.out.println("["
491: + retrievedMessage.getStringProperty("TESTString")
492: + "][TESTvalue]");
493: assertEquals(retrievedMessage.getStringProperty("TESTString"),
494: "TESTvalue");
495: retrievedMessage.setStringProperty("TESTString", "TESTvalue2");
496: assertEquals(
497: ((RPCMessage) retrievedMessage).getMethodBodyXML(),
498: "test text");
499: ((RPCMessage) retrievedMessage).setResult("result");
500: ((RPCMessage) retrievedMessage).setThrowable(new Exception(
501: "test"));
502: assertEquals(
503: retrievedMessage.getBooleanProperty("TESTBoolean"),
504: true);
505: retrievedMessage.setBooleanProperty("TESTBoolean", false);
506: assertEquals(retrievedMessage.getByteProperty("TESTByte"),
507: (byte) 1);
508: retrievedMessage.setByteProperty("TESTByte", (byte) 2);
509: assertEquals(retrievedMessage.getCorrelationId(),
510: "TESTCorrelationId");
511: retrievedMessage.setCorrelationId("TESTCorrelationId2");
512: assertEquals(retrievedMessage.getDoubleProperty("TESTDouble"),
513: (double) 1.1);
514: retrievedMessage.setDoubleProperty("TESTDouble", 2.5);
515: assertEquals(retrievedMessage.getFloatProperty("TESTFloat"),
516: (float) 2.2);
517: retrievedMessage.setFloatProperty("TESTFloat", (float) 4.4);
518: assertEquals(retrievedMessage.getFrom(), "test@test.com");
519: assertEquals(retrievedMessage.getIntProperty("TESTInt"), 100);
520: retrievedMessage.setIntProperty("TESTInt", 200);
521: assertEquals(retrievedMessage.getLongProperty("TESTLong"),
522: (long) 2000);
523: retrievedMessage.setLongProperty("TESTLong", (long) 4000);
524: assertEquals(retrievedMessage.getTargetNamedQueue(),
525: "QUEUEName");
526: assertEquals(retrievedMessage.getReplyNamedQueue(),
527: "ReplyQUEUEName");
528: assertEquals(((MessageImpl) retrievedMessage)
529: .getNextProcessDate().getTime() / 1000, currentTime
530: .getTime() / 1000);
531: ((MessageImpl) retrievedMessage)
532: .setNextProcessDate(nextProcessTime);
533: assertEquals(retrievedMessage.getObjectProperty("TESTObject"),
534: "This is a test obj");
535: retrievedMessage.setObjectProperty("TESTObject",
536: "this is a new object value");
537: assertEquals(retrievedMessage.getPriority(), 1000);
538: retrievedMessage.setPriority(2000);
539: assertEquals(
540: retrievedMessage.getProcessedDate().getTime() / 1000,
541: currentTime.getTime() / 1000);
542: retrievedMessage.setProcessedDate(nextProcessTime);
543: assertEquals(retrievedMessage.getReply(), true);
544: services = retrievedMessage.getServices();
545: foundCount = 0;
546: for (int index = 0; index < 3; index++) {
547: if (services[index].equals("test1")
548: || services[index].equals("test2")
549: || services[index].equals("test3")) {
550: foundCount++;
551: }
552: }
553: assertEquals(foundCount, 3);
554: assertEquals(retrievedMessage.getTarget(), "target");
555: assertEquals(retrievedMessage.getMessageCreater(), "test");
556: retrievedPrincipals = retrievedMessage.getMessagePrincipals();
557: if (retrievedPrincipals.size() != 1) {
558: fail("Invalid list principals");
559: }
560: if (!principals.equals(retrievedPrincipals)) {
561: fail("The retrieved principals are not equal.");
562: }
563:
564: ut.begin();
565: instance2.updateMessage(retrievedMessage);
566: instance2.assignToQueue("test");
567: ut.commit();
568:
569: ut.begin();
570: retrievedMessage = instance2.getMessage();
571:
572: ut.commit();
573:
574: assertEquals(retrievedMessage.getMessageId(), "test");
575: System.out.println("["
576: + retrievedMessage.getStringProperty("TESTString")
577: + "][TESTvalue2]");
578: assertEquals(retrievedMessage.getStringProperty("TESTString"),
579: "TESTvalue2");
580: assertEquals(
581: ((RPCMessage) retrievedMessage).getMethodBodyXML(),
582: "test text");
583: assertEquals(((RPCMessage) retrievedMessage).getResult(),
584: "result");
585: assertEquals(((RPCMessage) retrievedMessage).getThrowable()
586: .getMessage(), "test");
587: assertEquals(
588: retrievedMessage.getBooleanProperty("TESTBoolean"),
589: false);
590: assertEquals(retrievedMessage.getByteProperty("TESTByte"),
591: (byte) 2);
592: assertEquals(retrievedMessage.getDoubleProperty("TESTDouble"),
593: (double) 2.5);
594: assertEquals(retrievedMessage.getFloatProperty("TESTFloat"),
595: (float) 4.4);
596: assertEquals(retrievedMessage.getFrom(), "test@test.com");
597: assertEquals(retrievedMessage.getIntProperty("TESTInt"), 200);
598: assertEquals(retrievedMessage.getLongProperty("TESTLong"),
599: (long) 4000);
600: assertEquals(retrievedMessage.getTargetNamedQueue(),
601: "QUEUEName");
602: assertEquals(retrievedMessage.getReplyNamedQueue(),
603: "ReplyQUEUEName");
604: assertEquals(((MessageImpl) retrievedMessage)
605: .getNextProcessDate().getTime() / 1000, nextProcessTime
606: .getTime() / 1000);
607: assertEquals(retrievedMessage.getObjectProperty("TESTObject"),
608: "this is a new object value");
609: assertEquals(
610: retrievedMessage.getProcessedDate().getTime() / 1000,
611: nextProcessTime.getTime() / 1000);
612: assertEquals(retrievedMessage.getReply(), true);
613: assertEquals(retrievedMessage.getState(), Message.UNDELIVERED);
614: services = retrievedMessage.getServices();
615: foundCount = 0;
616: for (int index = 0; index < 3; index++) {
617: if (services[index].equals("test1")
618: || services[index].equals("test2")
619: || services[index].equals("test3")) {
620: foundCount++;
621: }
622: }
623: assertEquals(foundCount, 3);
624: assertEquals(retrievedMessage.getTarget(), "target");
625:
626: ut.begin();
627: instance2.remove();
628: ut.commit();
629:
630: Thread.sleep(30000);
631:
632: ChangeLog.getInstance().terminate();
633:
634: }
635:
636: }
|