User: user57 Date: 01/07/09 19:34:04 Modified: src/main/org/jboss/test/jbossmq/test Main.java Log: o changed all deploy tests to deploy as a test and to not call System.exit(). this should allow reports to be generated for tests that fail to deploy. o modified run_tests.xml basic-security-tests to not-halt on error, so that test-and-report will produce reports even if the security tests fail. Revision Changes Path 1.2 +173 -176 jbosstest/src/main/org/jboss/test/jbossmq/test/Main.java Index: Main.java =================================================================== RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/jbossmq/test/Main.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Main.java 2001/06/25 01:25:54 1.1 +++ Main.java 2001/07/10 02:34:04 1.2 @@ -29,212 +29,209 @@ * @author * @version */ - -public class Main extends junit.framework.TestCase { - - // Provider specific - static String TOPIC_FACTORY = "TopicConnectionFactory"; - static String QUEUE_FACTORY = "QueueConnectionFactory"; +public class Main + extends junit.framework.TestCase +{ + // Provider specific + static String TOPIC_FACTORY = "TopicConnectionFactory"; + static String QUEUE_FACTORY = "QueueConnectionFactory"; - static String TEST_QUEUE = "queue/testQueue"; - static String TEST_TOPIC = "topic/testTopic"; - - - + static String TEST_QUEUE = "queue/testQueue"; + static String TEST_TOPIC = "topic/testTopic"; - //JMSProviderAdapter providerAdapter; - static Context context; - static QueueConnection queueConnection; - static TopicConnection topicConnection; + //JMSProviderAdapter providerAdapter; + static Context context; + static QueueConnection queueConnection; + static TopicConnection topicConnection; - public Main(String name) throws Exception{ - super(name); - } + public Main(String name) throws Exception{ + super(name); + } - // Emptys out all the messages in a queue - private void drainQueue() throws Exception { + // Emptys out all the messages in a queue + private void drainQueue() throws Exception { - QueueSession session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); - Queue queue = (Queue)context.lookup(TEST_QUEUE); + QueueSession session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); + Queue queue = (Queue)context.lookup(TEST_QUEUE); - QueueReceiver receiver = session.createReceiver(queue); - Message message = receiver.receive( 2000 ); - int c=0; - while( message != null ) { - message = receiver.receive( 2000 ); - c++; - } + QueueReceiver receiver = session.createReceiver(queue); + Message message = receiver.receive( 2000 ); + int c=0; + while( message != null ) { + message = receiver.receive( 2000 ); + c++; + } - if( c!=0 ) - System.out.println(" Drained "+c+" messages from the queue"); + if( c!=0 ) + System.out.println(" Drained "+c+" messages from the queue"); - session.close(); + session.close(); - } + } - static public void main ( String []args ) { + static public void main ( String []args ) { - String newArgs[] = { "org.jboss.test.spydermq.test.Main" }; - junit.swingui.TestRunner.main(newArgs); + String newArgs[] = { "org.jboss.test.spydermq.test.Main" }; + junit.swingui.TestRunner.main(newArgs); - } + } - protected void connect() throws Exception { + protected void connect() throws Exception { - if( context == null ) { + if( context == null ) { - context = new InitialContext(); + context = new InitialContext(); - } - QueueConnectionFactory queueFactory = (QueueConnectionFactory) context.lookup(QUEUE_FACTORY); - queueConnection = queueFactory.createQueueConnection(); - - TopicConnectionFactory topicFactory = (TopicConnectionFactory)context.lookup(TOPIC_FACTORY); - topicConnection = topicFactory.createTopicConnection(); - - System.out.println("Connection to spyderMQ established."); - - } - - protected void disconnect() throws Exception { - queueConnection.close(); - topicConnection.close(); - } - - /** - * Test that messages are ordered by message arrival and priority. - * This also tests : - * Using a non-transacted AUTO_ACKNOWLEDGE session - * Using a QueueReceiver - * Using a QueueSender - * Sending PERSITENT and NON_PERSISTENT text messages. - * Using a QueueBrowser - */ - public void testQueueMessageOrder() throws Exception { - - System.out.println("Starting QueueMessageOrder test"); - - connect(); - - queueConnection.start(); - - drainQueue(); - - QueueSession session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); - Queue queue = (Queue)context.lookup(TEST_QUEUE); - QueueSender sender = session.createSender(queue); - - TextMessage message = session.createTextMessage(); - message.setText("Normal message"); - sender.send(queue, message, DeliveryMode.NON_PERSISTENT, 4, 0); - message.setText("Persistent message"); - sender.send(queue, message, DeliveryMode.PERSISTENT, 4, 0); - message.setText("High Priority Persistent message"); - sender.send(queue, message, DeliveryMode.PERSISTENT, 10, 0); - //message.setText("Expiring Persistent message"); - //sender.send(queue, message, DeliveryMode.NON_PERSISTENT, 4, 1); - - QueueBrowser browser = session.createBrowser( queue ); - Enumeration enum = browser.getEnumeration(); - //message = (TextMessage)enum.nextElement(); - //if( !message.getText().equals("High Priority Persistent message") ) - // throw new Exception("Queue is not prioritizing messages correctly. Unexpected Message:"+message); - System.out.println(message.getText()); - - message = (TextMessage)enum.nextElement(); - //if( !message.getText().equals("Normal message") ) - // throw new Exception("Queue is not ordering messages correctly. Unexpected Message:"+message); - System.out.println(message.getText()); - - message = (TextMessage)enum.nextElement(); - //if( !message.getText().equals("Persistent message") ) - // throw new Exception("Queue is not ordering messages correctly. Unexpected Message:"+message); - System.out.println(message.getText()); - - // if( enum.hasMoreElements() ) - // throw new Exception("Queue does not expire messages correctly. Unexpected Message:"+enum.nextElement()); - - disconnect(); - System.out.println("QueueMessageOrder passed"); - } - - /** - * Test that a using QueueRequestor works. - * this also tests that : - * temporary queues work. - */ - public void testRequestReplyQueue() throws Exception { - - System.out.println("Starting RequestReplyQueue test"); - connect(); - - { - queueConnection.start(); - drainQueue( ); - } - - Thread serverThread = new Thread() { - public void run() { - try { - - System.out.println("Server Thread Started"); - QueueSession session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); - Queue queue = (Queue)context.lookup(TEST_QUEUE); + } + QueueConnectionFactory queueFactory = (QueueConnectionFactory) context.lookup(QUEUE_FACTORY); + queueConnection = queueFactory.createQueueConnection(); + + TopicConnectionFactory topicFactory = (TopicConnectionFactory)context.lookup(TOPIC_FACTORY); + topicConnection = topicFactory.createTopicConnection(); + + System.out.println("Connection to spyderMQ established."); + + } + + protected void disconnect() throws Exception { + queueConnection.close(); + topicConnection.close(); + } + + /** + * Test that messages are ordered by message arrival and priority. + * This also tests : + * Using a non-transacted AUTO_ACKNOWLEDGE session + * Using a QueueReceiver + * Using a QueueSender + * Sending PERSITENT and NON_PERSISTENT text messages. + * Using a QueueBrowser + */ + public void testQueueMessageOrder() throws Exception { + + System.out.println("Starting QueueMessageOrder test"); + + connect(); + + queueConnection.start(); + + drainQueue(); + + QueueSession session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); + Queue queue = (Queue)context.lookup(TEST_QUEUE); + QueueSender sender = session.createSender(queue); + + TextMessage message = session.createTextMessage(); + message.setText("Normal message"); + sender.send(queue, message, DeliveryMode.NON_PERSISTENT, 4, 0); + message.setText("Persistent message"); + sender.send(queue, message, DeliveryMode.PERSISTENT, 4, 0); + message.setText("High Priority Persistent message"); + sender.send(queue, message, DeliveryMode.PERSISTENT, 10, 0); + //message.setText("Expiring Persistent message"); + //sender.send(queue, message, DeliveryMode.NON_PERSISTENT, 4, 1); + + QueueBrowser browser = session.createBrowser( queue ); + Enumeration enum = browser.getEnumeration(); + //message = (TextMessage)enum.nextElement(); + //if( !message.getText().equals("High Priority Persistent message") ) + // throw new Exception("Queue is not prioritizing messages correctly. Unexpected Message:"+message); + System.out.println(message.getText()); + + message = (TextMessage)enum.nextElement(); + //if( !message.getText().equals("Normal message") ) + // throw new Exception("Queue is not ordering messages correctly. Unexpected Message:"+message); + System.out.println(message.getText()); + + message = (TextMessage)enum.nextElement(); + //if( !message.getText().equals("Persistent message") ) + // throw new Exception("Queue is not ordering messages correctly. Unexpected Message:"+message); + System.out.println(message.getText()); + + // if( enum.hasMoreElements() ) + // throw new Exception("Queue does not expire messages correctly. Unexpected Message:"+enum.nextElement()); + + disconnect(); + System.out.println("QueueMessageOrder passed"); + } + + /** + * Test that a using QueueRequestor works. + * this also tests that : + * temporary queues work. + */ + public void testRequestReplyQueue() throws Exception { + + System.out.println("Starting RequestReplyQueue test"); + connect(); + + { + queueConnection.start(); + drainQueue( ); + } + + Thread serverThread = new Thread() { + public void run() { + try { + + System.out.println("Server Thread Started"); + QueueSession session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); + Queue queue = (Queue)context.lookup(TEST_QUEUE); - QueueReceiver queueReceiver = session.createReceiver(queue); + QueueReceiver queueReceiver = session.createReceiver(queue); - boolean done = false; - while ( !done ) { - TextMessage message = (TextMessage) queueReceiver.receive(); - Queue tempQueue = (Queue) message.getJMSReplyTo(); + boolean done = false; + while ( !done ) { + TextMessage message = (TextMessage) queueReceiver.receive(); + Queue tempQueue = (Queue) message.getJMSReplyTo(); - QueueSender replySender = session.createSender(tempQueue); - TextMessage reply = session.createTextMessage(); - reply.setText("Request Processed"); - reply.setJMSCorrelationID(message.getJMSMessageID()); - replySender.send(reply); - - if( message.getText().equals("Quit") ) - done = true; - } + QueueSender replySender = session.createSender(tempQueue); + TextMessage reply = session.createTextMessage(); + reply.setText("Request Processed"); + reply.setJMSCorrelationID(message.getJMSMessageID()); + replySender.send(reply); + + if( message.getText().equals("Quit") ) + done = true; + } - session.close(); - System.out.println("Server Thread Finished"); + session.close(); + System.out.println("Server Thread Finished"); - } catch ( Exception e ) { - e.printStackTrace(); - } - } - }; + } catch ( Exception e ) { + e.printStackTrace(); + } + } + }; - serverThread.start(); + serverThread.start(); - QueueSession session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); - Queue queue = (Queue)context.lookup(TEST_QUEUE); + QueueSession session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); + Queue queue = (Queue)context.lookup(TEST_QUEUE); - QueueRequestor queueRequestor = new QueueRequestor(session, queue); - TextMessage message = session.createTextMessage(); - message.setText("Request Test"); + QueueRequestor queueRequestor = new QueueRequestor(session, queue); + TextMessage message = session.createTextMessage(); + message.setText("Request Test"); - for( int i=0; i < 5; i ++ ) { + for( int i=0; i < 5; i ++ ) { - System.out.println("Making client request #"+i); - TextMessage reply = (TextMessage) queueRequestor.request(message); - String replyID = new String(reply.getJMSCorrelationID()); - if (!replyID.equals(message.getJMSMessageID())) - throw new Exception("REQUEST: ERROR: Reply does not match sent message"); + System.out.println("Making client request #"+i); + TextMessage reply = (TextMessage) queueRequestor.request(message); + String replyID = new String(reply.getJMSCorrelationID()); + if (!replyID.equals(message.getJMSMessageID())) + throw new Exception("REQUEST: ERROR: Reply does not match sent message"); - } + } - System.out.println("Making client request to shut server down."); - message.setText("Quit"); - queueRequestor.request(message); + System.out.println("Making client request to shut server down."); + message.setText("Quit"); + queueRequestor.request(message); - serverThread.join(); - disconnect(); + serverThread.join(); + disconnect(); - System.out.println("RequestReplyQueue passed"); - } + System.out.println("RequestReplyQueue passed"); + } } _______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] http://lists.sourceforge.net/lists/listinfo/jboss-development