Commit 0bc1f221 authored by afreyssin's avatar afreyssin

Minor changes.

parent 103dd915
/*
* 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();
}
}
}
/*
* 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();
}
}
}
......@@ -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();
}
}
}
/*
* 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<ids.length; i++) {
queue.deleteMessage(ids[i]);
}
for (int i = 0; i < ids.length; i++) {
queue.deleteMessage(ids[i]);
}
//System.out.println("after clear -> " + 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();
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment