01: /*
02: * ChainBuilder ESB
03: * Visual Enterprise Integration
04: *
05: * Copyright (C) 2006 Bostech Corporation
06: *
07: * This program is free software; you can redistribute it and/or modify
08: * it under the terms of the GNU General Public License as published by
09: * the Free Software Foundation; either version 2 of the License, or
10: * (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public License
18: * along with this program; if not, write to the Free Software
19: * Foundation, Inc.,59 Temple Place, Suite 330, Boston, MA 02111-1307
20: * USA
21: *
22: *
23: *
24: */
25: package com.bostechcorp.cbesb.runtime.jms.test;
26:
27: import java.util.Random;
28:
29: import javax.jms.QueueSession;
30: import javax.jms.Session;
31: import javax.jms.TextMessage;
32:
33: import junit.framework.TestCase;
34:
35: import com.bostechcorp.cbesb.runtime.jms.JMSException;
36: import com.bostechcorp.cbesb.runtime.jms.JMSHandler;
37:
38: public class TestJMS extends TestCase {
39:
40: private JMSHandler jmsHandler = new JMSHandler();
41:
42: public void testInitialize() throws Throwable {
43: try {
44: jmsHandler.initialize(
45: "com.sun.jndi.fscontext.RefFSContextFactory",
46: "file:/C:/CBESB/JndiDir", "ivtQCF", null, null);
47: } catch (JMSException e) {
48: e.printStackTrace();
49: }
50: }
51:
52: public void testSend() throws Throwable {
53: QueueSession session = JMSHandler.getConnection()
54: .createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
55:
56: TextMessage sendMessage = session.createTextMessage();
57: sendMessage.setText("¶þ×Ó");
58: sendMessage.setJMSMessageID("ID:"
59: + Long
60: .toHexString((new Long((new Random())
61: .nextLong()))));
62:
63: TextMessage receivedMessage = (TextMessage) jmsHandler.send(
64: "queue", "postcard", "default", 10 * 1000, sendMessage);
65:
66: System.out.println("Received Message: "
67: + receivedMessage.getText());
68: }
69:
70: /*public void testReceive() throws Throwable {
71: TextMessage receivedMessage = (TextMessage)jmsHandler.receive("queue", "postcard");
72:
73: System.out.println("Received Message: "+receivedMessage.getText());
74: }*/
75: }
|