diff --git a/tests/src/joram/noreg/Test35.java b/tests/src/joram/noreg/Test35.java index 3f9e9fee5b3225ddc16024676486ab172f56f1c0..ad899b8873fdb0b9206630fcac14845162f04d33 100644 --- a/tests/src/joram/noreg/Test35.java +++ b/tests/src/joram/noreg/Test35.java @@ -1,6 +1,6 @@ /* * JORAM: Java(TM) Open Reliable Asynchronous Messaging - * Copyright (C) 2003 - 2009 ScalAgent Distributed Technologies + * Copyright (C) 2003 - 2017 ScalAgent Distributed Technologies * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -31,52 +31,53 @@ import org.objectweb.joram.client.jms.admin.AdminModule; import fr.dyade.aaa.agent.AgentServer; /** - *test getadminname + * test getadminname */ public class Test35 extends BaseTest { - public final static String queueName = "myQueue"; - public final static String topicName = "myTopic"; + public final static String queueName = "myQueue"; + public final static String topicName = "myTopic"; - public static void main (String args[]) throws Exception { - new Test35().run(); - } - public void run(){ - try{ - startServer(); + public static void main(String args[]) throws Exception { + new Test35().run(); + } + + public void run() { + try { + startServer(); + + String baseclass = "joram.noreg.ColocatedBaseTest"; + baseclass = System.getProperty("BaseClass", baseclass); - String baseclass = "joram.noreg.ColocatedBaseTest"; - baseclass = System.getProperty("BaseClass", baseclass); + AdminModule.connect(createConnectionFactory(baseclass)); - AdminModule.connect(createConnectionFactory(baseclass)); + Queue queue = Queue.create(queueName); + Topic topic = Topic.create(topicName); - Queue queue = Queue.create(queueName); - Topic topic = Topic.create(topicName); + InitialContext jndi = new InitialContext(); + jndi.rebind(queueName, queue); + jndi.rebind(topicName, topic); - InitialContext jndi = new InitialContext(); - jndi.rebind(queueName, queue); - jndi.rebind(topicName, topic); + // System.out.println(queue.getAdminName()); + // System.out.println(topic.getAdminName()); + assertEquals("myQueue", queue.getAdminName()); + assertEquals("myTopic", topic.getAdminName()); - //System.out.println(queue.getAdminName()); - //System.out.println(topic.getAdminName()); - assertEquals("myQueue",queue.getAdminName()); - assertEquals("myTopic",topic.getAdminName()); - - Queue queue1 = (Queue) jndi.lookup(queueName); - Topic topic1 = (Topic) jndi.lookup(topicName); + Queue queue1 = (Queue) jndi.lookup(queueName); + Topic topic1 = (Topic) jndi.lookup(topicName); - //System.out.println(queue1.getAdminName()); - //System.out.println(topic1.getAdminName()); - assertEquals("myQueue",queue1.getAdminName()); - assertEquals("myTopic",topic1.getAdminName()); + // System.out.println(queue1.getAdminName()); + // System.out.println(topic1.getAdminName()); + assertEquals("myQueue", queue1.getAdminName()); + assertEquals("myTopic", topic1.getAdminName()); - AdminModule.disconnect(); + AdminModule.disconnect(); - }catch(Throwable exc){ - exc.printStackTrace(); - error(exc); - }finally{ - AgentServer.stop(); - endTest(); - } + } catch (Throwable exc) { + exc.printStackTrace(); + error(exc); + } finally { + AgentServer.stop(); + endTest(); } + } } diff --git a/tests/src/joram/noreg/Test41.java b/tests/src/joram/noreg/Test41.java index 300f864525019bfc04275b0820c26b81a5fb92ae..4dce01c51ac9366754398604101dde48ee7be64d 100644 --- a/tests/src/joram/noreg/Test41.java +++ b/tests/src/joram/noreg/Test41.java @@ -1,6 +1,6 @@ /* * JORAM: Java(TM) Open Reliable Asynchronous Messaging - * Copyright (C) 2003 - 2007 ScalAgent Distributed Technologies + * Copyright (C) 2003 - 2017 ScalAgent Distributed Technologies * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -38,84 +38,85 @@ import org.objectweb.joram.client.jms.tcp.TcpConnectionFactory; import fr.dyade.aaa.agent.AgentServer; - - /** - * test messagelistener with RuntimeException. message is redelivred - * + * Tests messagelistener with RuntimeException. message is redelivred. */ -public class Test41 extends BaseTest implements MessageListener { - static Connection cnx; - static Session session1, session2; - static int cpt; - public static void main (String args[]) { - new Test41().run(); - } - public void run(){ - try{ - cpt=0; - AgentServer.init((short) 0, "s0", null); - AgentServer.start(); - - Thread.sleep(1000L); - - AdminModule.connect("localhost", 16010, "root", "root", 60); - - User user = User.create("anonymous", "anonymous"); - Queue queue = Queue.create(0); - queue.setFreeReading(); - queue.setFreeWriting(); - - ConnectionFactory cf = TcpConnectionFactory.create("localhost", 16010); - AdminModule.disconnect(); - - cnx = cf.createConnection(); - session1 = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer prod = session1.createProducer(queue); - - session2 = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageConsumer cons = session2.createConsumer(queue); - cons.setMessageListener(this); - cnx.start(); - - Message msg = session1.createMessage(); - msg.setIntProperty("Index", 0); - prod.send(msg); - - Thread.sleep(1000L); - msg = session1.createMessage(); - msg.setIntProperty("Index", 1); - prod.send(msg); - - Thread.sleep(1000L); - - session1.close(); - session2.close(); - cnx.close(); - }catch(Throwable exc){ - exc.printStackTrace(); - error(exc); - }finally{ - AgentServer.stop(); - endTest(); - } +public class Test41 extends BaseTest implements MessageListener { + static Connection cnx; + static Session session1, session2; + static int cpt; + + public static void main(String args[]) { + new Test41().run(); + } + + public void run() { + try { + cpt = 0; + AgentServer.init((short) 0, "s0", null); + AgentServer.start(); + + Thread.sleep(1000L); + + AdminModule.connect("localhost", 16010, "root", "root", 60); + + User user = User.create("anonymous", "anonymous"); + Queue queue = Queue.create(0); + queue.setFreeReading(); + queue.setFreeWriting(); + + ConnectionFactory cf = TcpConnectionFactory.create("localhost", 16010); + AdminModule.disconnect(); + + cnx = cf.createConnection(); + session1 = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE); + MessageProducer prod = session1.createProducer(queue); + + session2 = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE); + MessageConsumer cons = session2.createConsumer(queue); + cons.setMessageListener(this); + cnx.start(); + + Message msg = session1.createMessage(); + msg.setIntProperty("Index", 0); + prod.send(msg); + + Thread.sleep(1000L); + msg = session1.createMessage(); + msg.setIntProperty("Index", 1); + prod.send(msg); + + Thread.sleep(1000L); + + session1.close(); + session2.close(); + cnx.close(); + } catch (Throwable exc) { + exc.printStackTrace(); + error(exc); + } finally { + AgentServer.stop(); + endTest(); } - public synchronized void onMessage(Message msg) { - - try { - cpt += 1; - int index = msg.getIntProperty("Index"); - - if (cpt < 3){ - // System.out.println("receives msg#" + index + " should be msg#0"); - assertEquals(0,index); - }/* else{ - System.out.println("receives msg#" + index); - }*/ - if (cpt == 1) throw new RuntimeException(); - - } catch (JMSException exc) { - exc.printStackTrace(); - } + } + + public synchronized void onMessage(Message msg) { + + try { + cpt += 1; + int index = msg.getIntProperty("Index"); + + if (cpt < 3) { + // System.out.println("receives msg#" + index + " should be msg#0"); + assertEquals(0, index); +// } else{ +// System.out.println("receives msg#" + index); + } + if (cpt == 1) + throw new RuntimeException(); + + } catch (JMSException exc) { + exc.printStackTrace(); } + } } diff --git a/tests/src/joram/noreg/Test48.java b/tests/src/joram/noreg/Test48.java index 6fa0909aba4af321d2d1d51a3a5968c1a9275f91..53f9323d8d3f758cac871b70c4d6480601a979cc 100644 --- a/tests/src/joram/noreg/Test48.java +++ b/tests/src/joram/noreg/Test48.java @@ -33,76 +33,75 @@ import org.objectweb.joram.client.jms.admin.AdminModule; import org.objectweb.joram.client.jms.admin.User; import org.objectweb.joram.client.jms.tcp.TcpConnectionFactory; - /** * test queue.clear() , restart of server, and check there is no message * */ - public class Test48 extends BaseTest { - public static void main (String args[]) { - new Test48().run(); - } - public void run(){ - try { - framework.TestCase.startAgentServer((short) 0); - Thread.sleep(1000L); - - AdminModule.connect("root", "root", 60); - User user = User.create("anonymous", "anonymous"); - Queue queue = Queue.create(0, "queue"); - queue.setFreeReading(); - queue.setFreeWriting(); - // AdminModule.disconnect(); - ConnectionFactory cf = TcpConnectionFactory.create("localhost", 16010); - - Connection cnx = cf.createConnection(); - - Session sess = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer prod = sess.createProducer(queue); - cnx.start(); - - for (int i=0; i<10; i++) { - Message msg = sess.createMessage(); - msg.setIntProperty("Index", i); - prod.send( msg); - } - - sess.close(); - cnx.close(); + public static void main(String args[]) { + new Test48().run(); + } + + public void run() { + try { + framework.TestCase.startAgentServer((short) 0); + Thread.sleep(1000L); + + AdminModule.connect("root", "root", 60); + User user = User.create("anonymous", "anonymous"); + Queue queue = Queue.create(0, "queue"); + queue.setFreeReading(); + queue.setFreeWriting(); + // AdminModule.disconnect(); + ConnectionFactory cf = TcpConnectionFactory.create("localhost", 16010); + + Connection cnx = cf.createConnection(); + + Session sess = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE); + MessageProducer prod = sess.createProducer(queue); + cnx.start(); + + for (int i = 0; i < 10; i++) { + Message msg = sess.createMessage(); + msg.setIntProperty("Index", i); + prod.send(msg); + } + + sess.close(); + cnx.close(); //System.out.println("before clear -> " + queue.getPendingMessages() + " should be 10"); - assertEquals(10,queue.getPendingMessages()); - queue.clear(); + assertEquals(10, queue.getPendingMessages()); + queue.clear(); //System.out.println("after clear -> " + queue.getPendingMessages() +" should be 0"); - assertEquals(0,queue.getPendingMessages()); - - AdminModule.disconnect(); - - Thread.sleep(1000L); - System.out.println("Stop Server#0"); - framework.TestCase.stopAgentServer((short) 0); - Thread.sleep(1000L); - System.out.println("Start Server#0"); - framework.TestCase.startAgentServer((short) 0); - Thread.sleep(1000L); - - AdminModule.connect("root", "root", 60); - queue = Queue.create(0, "queue"); + assertEquals(0, queue.getPendingMessages()); + + AdminModule.disconnect(); + + Thread.sleep(1000L); + System.out.println("Stop Server#0"); + framework.TestCase.stopAgentServer((short) 0); + Thread.sleep(1000L); + System.out.println("Start Server#0"); + framework.TestCase.startAgentServer((short) 0); + Thread.sleep(1000L); + + AdminModule.connect("root", "root", 60); + queue = Queue.create(0, "queue"); // System.out.println("after restart -> " + queue.getPendingMessages() +" should be 0"); - assertEquals(0,queue.getPendingMessages()); - - AdminModule.disconnect(); - - Thread.sleep(1000L); - - } catch (Exception exc) { - exc.printStackTrace(); - error(exc); - }finally{ - System.out.println("Stop Server#0"); - framework.TestCase.stopAgentServer((short) 0); - endTest(); - } + assertEquals(0, queue.getPendingMessages()); + + AdminModule.disconnect(); + + Thread.sleep(1000L); + + } catch (Exception exc) { + exc.printStackTrace(); + error(exc); + } finally { + System.out.println("Stop Server#0"); + framework.TestCase.stopAgentServer((short) 0); + endTest(); } + } } diff --git a/tests/src/joram/noreg/Test49.java b/tests/src/joram/noreg/Test49.java index 0cd9ccc20f41ed9d57b46371f3823239faf4e4d6..c296dac35655d54ad7674986dd043a0df25af1d7 100644 --- a/tests/src/joram/noreg/Test49.java +++ b/tests/src/joram/noreg/Test49.java @@ -1,6 +1,6 @@ /* * JORAM: Java(TM) Open Reliable Asynchronous Messaging - * Copyright (C) 2003 - 2007 ScalAgent Distributed Technologies + * Copyright (C) 2003 - 2017 ScalAgent Distributed Technologies * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -33,77 +33,76 @@ import org.objectweb.joram.client.jms.admin.AdminModule; import org.objectweb.joram.client.jms.admin.User; import org.objectweb.joram.client.jms.tcp.TcpConnectionFactory; - /** - * test queue.deleteMessage() , restart of server, and check there is no message - * + * Tests queue.deleteMessage() , restart of server, and check there is no message. */ public class Test49 extends BaseTest { - public static void main (String args[]) { - new Test49().run(); - } - public void run(){ - try { - framework.TestCase.startAgentServer((short) 0); - Thread.sleep(1000L); - - AdminModule.connect("root", "root", 60); - User user = User.create("anonymous", "anonymous"); - Queue queue = Queue.create(0, "queue"); - queue.setFreeReading(); - queue.setFreeWriting(); - // AdminModule.disconnect(); - ConnectionFactory cf = TcpConnectionFactory.create("localhost", 16010); - - Connection cnx = cf.createConnection(); - - Session sess = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer prod = sess.createProducer(queue); - cnx.start(); - - for (int i=0; i<10; i++) { - Message msg = sess.createMessage(); - msg.setIntProperty("Index", i); - prod.send( msg); - } - - sess.close(); - cnx.close(); - + public static void main(String args[]) { + new Test49().run(); + } + + public void run() { + try { + framework.TestCase.startAgentServer((short) 0); + Thread.sleep(1000L); + + AdminModule.connect("root", "root", 60); + User user = User.create("anonymous", "anonymous"); + Queue queue = Queue.create(0, "queue"); + queue.setFreeReading(); + queue.setFreeWriting(); + // AdminModule.disconnect(); + ConnectionFactory cf = TcpConnectionFactory.create("localhost", 16010); + + Connection cnx = cf.createConnection(); + + Session sess = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE); + MessageProducer prod = sess.createProducer(queue); + cnx.start(); + + for (int i = 0; i < 10; i++) { + Message msg = sess.createMessage(); + msg.setIntProperty("Index", i); + prod.send(msg); + } + + sess.close(); + cnx.close(); + //System.out.println("before clear -> " + queue.getPendingMessages() +" should be 10"); - assertEquals(10, queue.getPendingMessages()); - String ids[] = queue.getMessageIds(); + assertEquals(10, queue.getPendingMessages()); + String ids[] = queue.getMessageIds(); - for (int i=0; i " + queue.getPendingMessages() +" should be 0"); - assertEquals(0, queue.getPendingMessages()); - AdminModule.disconnect(); + assertEquals(0, queue.getPendingMessages()); + AdminModule.disconnect(); - Thread.sleep(1000L); - System.out.println("Stop Server#0"); - framework.TestCase.stopAgentServer((short) 0); - Thread.sleep(1000L); - System.out.println("Start Server#0"); - framework.TestCase.startAgentServer((short) 0); - Thread.sleep(1000L); + Thread.sleep(1000L); + System.out.println("Stop Server#0"); + framework.TestCase.stopAgentServer((short) 0); + Thread.sleep(1000L); + System.out.println("Start Server#0"); + framework.TestCase.startAgentServer((short) 0); + Thread.sleep(1000L); - AdminModule.connect("root", "root", 60); - queue = Queue.create(0, "queue"); + AdminModule.connect("root", "root", 60); + queue = Queue.create(0, "queue"); //System.out.println("after restart -> " + queue.getPendingMessages() +" should be 0"); - assertEquals(0, queue.getPendingMessages()); - AdminModule.disconnect(); + assertEquals(0, queue.getPendingMessages()); + AdminModule.disconnect(); + + Thread.sleep(1000L); - Thread.sleep(1000L); - - } catch (Exception exc) { - exc.printStackTrace(); - error(exc); - }finally{ - System.out.println("Stop Server#0"); - framework.TestCase.stopAgentServer((short) 0); - endTest(); - } + } catch (Exception exc) { + exc.printStackTrace(); + error(exc); + } finally { + System.out.println("Stop Server#0"); + framework.TestCase.stopAgentServer((short) 0); + endTest(); } + } }