1 /* 2 * @(#)CorrelationIDTest.java 3 * 4 * JFoxMQ the open source JMS MOM. 5 * 6 * Corpyright 2002-2003 Huihoo Power, Inc. All Rights Reserved. This software 7 * is licensed under LGPL license. 8 * 9 * For more information, please visit: http://www.huihoo.org 10 */ 11 12 package org.huihoo.jfox.ms.jms.message; 13 14 import javax.jms.JMSException; 15 16 import junit.framework.TestCase; 17 18 /*** 19 * <p> 20 * JUnit test case for the {@link org.huihoo.jfoxms.jms.message.CorrelationID). 21 * </p> 22 * 23 * @author <a href="mailto:founder_chen@yahoo.com.cn">Peter.Cheng</a> 24 * @version Revision: 1.1 Date: 2002-11-13 21:52:22 25 */ 26 27 public class CorrelationIDTest extends TestCase { 28 29 private CorrelationID correlationID1; 30 private CorrelationID correlationID2; 31 private CorrelationID correlationID3; 32 private CorrelationID correlationID4; 33 private CorrelationID correlationID5; 34 35 /*** 36 * Constructor for CorrelationIDTest. 37 * 38 * @param arg0 39 */ 40 public CorrelationIDTest(String arg0) { 41 super(arg0); 42 } 43 44 public static void main(String[] args) { 45 junit.textui.TestRunner.run(CorrelationIDTest.class); 46 } 47 48 /*** 49 * @see TestCase#setUp() 50 */ 51 protected void setUp() { 52 correlationID1 = new CorrelationID(); 53 try { 54 correlationID2 = new CorrelationID("MyCorrealtionID12345"); 55 } catch (JMSException e) { 56 e.printStackTrace(); 57 System.out.println(e.getMessage()); 58 } 59 String correlationIDByteStr = "ByteCorrelationID"; 60 try { 61 correlationID3 = new CorrelationID(correlationIDByteStr.getBytes()); 62 } catch (JMSException e) { 63 e.printStackTrace(); 64 System.out.println(e.getMessage()); 65 } 66 } 67 68 /* 69 * Test for void CorrelationID() 70 */ 71 public void testCorrelationID() { 72 String expected = "CorelationID "; 73 assertEquals(expected, correlationID1.toString()); 74 } 75 76 /* 77 * Test for void CorrelationID(String) 78 */ 79 public void testCorrelationIDString() { 80 String expected = "MyCorrealtionID12345"; 81 try { 82 assertEquals(expected, correlationID2.getStringID()); 83 } catch (JMSException e) { 84 e.printStackTrace(); 85 } 86 } 87 88 /* 89 * Test for void CorrelationID(byte[]) 90 */ 91 public void testCorrelationIDBArray() { 92 String expectedStr = "ByteCorrelationID"; 93 byte[] expected = expectedStr.getBytes(); 94 95 try { 96 byte[] byteID = correlationID3.getBytesID(); 97 for (int i = 0; i < byteID.length; i++) { 98 assertEquals(expected[i], byteID[i]); 99 } 100 } catch (JMSException e) { 101 e.printStackTrace(); 102 System.out.println(e.getMessage()); 103 } 104 } 105 }

This page was automatically generated by Maven