Commit 0bc1f221 authored by afreyssin's avatar afreyssin

Minor changes.

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