Commit 51049db2 authored by Guillaume Surrel's avatar Guillaume Surrel

Adapt tests to new DMQ properties.

parent 21734037
......@@ -42,6 +42,7 @@ import org.objectweb.joram.client.jms.admin.AdminModule;
import org.objectweb.joram.client.jms.admin.DeadMQueue;
import org.objectweb.joram.client.jms.admin.User;
import org.objectweb.joram.client.jms.tcp.TcpConnectionFactory;
import org.objectweb.joram.shared.MessageErrorConstants;
/**
* Test that a message body is not deleted on a DMQ after server restart
......@@ -100,7 +101,8 @@ public class Test_DMQ_Body extends TestCase {
TextMessage msg1 = (TextMessage) messages.nextElement();
System.out.println("message expired !");
//test messages
assertEquals(true, msg1.getBooleanProperty("JMS_JORAM_EXPIRED"));
assertEquals(1, msg1.getIntProperty("JMS_JORAM_ERRORCOUNT"));
assertEquals(MessageErrorConstants.EXPIRED, msg1.getIntProperty("JMS_JORAM_ERRORCODE_1"));
assertEquals(msg.getJMSMessageID(), msg1.getJMSMessageID());
assertEquals(msg.getJMSType(), msg1.getJMSType());
assertEquals("test not delete", msg1.getText());
......@@ -126,7 +128,8 @@ public class Test_DMQ_Body extends TestCase {
while (messages.hasMoreElements()) {
TextMessage msg1 = (TextMessage) messages.nextElement();
assertEquals(true, msg1.getBooleanProperty("JMS_JORAM_EXPIRED"));
assertEquals(1, msg1.getIntProperty("JMS_JORAM_ERRORCOUNT"));
assertEquals(MessageErrorConstants.EXPIRED, msg1.getIntProperty("JMS_JORAM_ERRORCODE_1"));
assertEquals(msg.getJMSMessageID(), msg1.getJMSMessageID());
assertEquals(msg.getJMSType(), msg1.getJMSType());
assertEquals("test not delete", msg1.getText());
......
......@@ -35,6 +35,7 @@ import javax.naming.InitialContext;
import joram.framework.TestCase;
import org.objectweb.joram.client.jms.admin.DeadMQueue;
import org.objectweb.joram.shared.MessageErrorConstants;
/**
* Test that a message is delete on a queue when time expired. Use a deadqueue to verify
......@@ -97,7 +98,8 @@ public class Test_Exp_Q extends TestCase {
// but the message is in the deadqueue
msg1= consumer_dead.receive(3000);
assertEquals(true, msg1.getBooleanProperty("JMS_JORAM_EXPIRED"));
assertEquals(1, msg1.getIntProperty("JMS_JORAM_ERRORCOUNT"));
assertEquals(MessageErrorConstants.EXPIRED, msg1.getIntProperty("JMS_JORAM_ERRORCODE_1"));
assertEquals(msg.getJMSMessageID(),msg1.getJMSMessageID());
assertEquals(msg.getJMSType(),msg1.getJMSType());
assertEquals(msg.getJMSDestination(),msg1.getJMSDestination());
......
......@@ -37,6 +37,7 @@ import javax.jms.TemporaryQueue;
import joram.framework.TestCase;
import org.objectweb.joram.client.jms.admin.AdminModule;
import org.objectweb.joram.client.jms.admin.User;
/**
* Testing:
......@@ -62,9 +63,7 @@ public class ClientTest8 extends TestCase {
AdminModule.connect("localhost", 2560,
"root", "root", 60);
org.objectweb.joram.client.jms.admin.User user =
org.objectweb.joram.client.jms.admin.User.create(
"anonymous", "anonymous", 0);
User.create("anonymous", "anonymous", 0);
ConnectionFactory cf =
org.objectweb.joram.client.jms.tcp.TcpConnectionFactory.create(
......@@ -75,8 +74,7 @@ public class ClientTest8 extends TestCase {
connection.setExceptionListener(
new ExceptionListener() {
public void onException(JMSException exc) {
// System.out.println("BUG -> " + exc);
excp=exc;
excp = exc;
}
});
......
......@@ -40,6 +40,7 @@ import joram.framework.TestCase;
import org.objectweb.joram.client.jms.admin.AdminModule;
import org.objectweb.joram.client.jms.admin.DeadMQueue;
import org.objectweb.joram.client.jms.tcp.TcpConnectionFactory;
import org.objectweb.joram.shared.MessageErrorConstants;
/**
* Some messages with a TTL are sent to a queue. When they are expired, they go
......@@ -115,24 +116,28 @@ public class ChainedDMQ extends TestCase {
// Check some message properties on DMQ 0
consumer = session.createConsumer(dmqueue0);
msg = (TextMessage) consumer.receive();
assertTrue(msg.getBooleanProperty("JMS_JORAM_EXPIRED"));
System.out.println("Expired at: " + msg.getLongProperty("JMS_JORAM_EXPIRATIONDATE"));
assertFalse(msg.getBooleanProperty("JMS_JORAM_NOTWRITABLE"));
assertFalse(msg.getBooleanProperty("JMS_JORAM_UNDELIVERABLE"));
assertFalse(msg.getBooleanProperty("JMS_JORAM_ADMINDELETED"));
assertFalse(msg.getBooleanProperty("JMS_JORAM_DELETEDDEST"));
assertFalse(msg.getBooleanProperty("JMS_JORAM_QUEUEFULL"));
assertEquals(1, msg.getIntProperty("JMS_JORAM_ERRORCOUNT"));
assertEquals(MessageErrorConstants.EXPIRED, msg.getShortProperty("JMS_JORAM_ERRORCODE_1"));
System.out.println(" ");
System.out.println("Message on DMQ0:");
System.out.println(msg.getStringProperty("JMS_JORAM_ERRORCAUSE_1"));
// Check some message properties on DMQ 3
consumer = session.createConsumer(dmqueue3);
msg = (TextMessage) consumer.receive();
assertTrue(msg.getBooleanProperty("JMS_JORAM_EXPIRED"));
System.out.println("Expired at: " + msg.getLongProperty("JMS_JORAM_EXPIRATIONDATE"));
assertFalse(msg.getBooleanProperty("JMS_JORAM_NOTWRITABLE"));
assertFalse(msg.getBooleanProperty("JMS_JORAM_UNDELIVERABLE"));
assertFalse(msg.getBooleanProperty("JMS_JORAM_ADMINDELETED"));
assertFalse(msg.getBooleanProperty("JMS_JORAM_DELETEDDEST"));
assertTrue(msg.getBooleanProperty("JMS_JORAM_QUEUEFULL"));
assertEquals(4, msg.getIntProperty("JMS_JORAM_ERRORCOUNT"));
assertEquals(MessageErrorConstants.EXPIRED, msg.getShortProperty("JMS_JORAM_ERRORCODE_1"));
assertEquals(MessageErrorConstants.QUEUE_FULL, msg.getShortProperty("JMS_JORAM_ERRORCODE_2"));
assertEquals(MessageErrorConstants.QUEUE_FULL, msg.getShortProperty("JMS_JORAM_ERRORCODE_3"));
assertEquals(MessageErrorConstants.QUEUE_FULL, msg.getShortProperty("JMS_JORAM_ERRORCODE_4"));
System.out.println(" ");
System.out.println("Message on DMQ3:");
System.out.println(msg.getStringProperty("JMS_JORAM_ERRORCAUSE_1"));
System.out.println(msg.getStringProperty("JMS_JORAM_ERRORCAUSE_2"));
System.out.println(msg.getStringProperty("JMS_JORAM_ERRORCAUSE_3"));
System.out.println(msg.getStringProperty("JMS_JORAM_ERRORCAUSE_4"));
} catch (Throwable exc) {
exc.printStackTrace();
......
......@@ -32,11 +32,14 @@ import javax.jms.MessageListener;
import javax.jms.MessageProducer;
import javax.jms.Session;
import joram.framework.BaseTestCase;
import org.objectweb.joram.client.jms.Queue;
import org.objectweb.joram.client.jms.admin.AdminModule;
import org.objectweb.joram.client.jms.admin.DeadMQueue;
import org.objectweb.joram.client.jms.admin.User;
import org.objectweb.joram.client.jms.tcp.TcpConnectionFactory;
import org.objectweb.joram.shared.MessageErrorConstants;
import fr.dyade.aaa.agent.AgentServer;
......@@ -57,14 +60,14 @@ class ExcList20 implements ExceptionListener {
}
class MsgList20B implements MessageListener {
public void onMessage(Message msg) {
try {
Test20.assertEquals(true,msg.getBooleanProperty("JMS_JORAM_EXPIRED"));
} catch(Exception exc) {
exc.printStackTrace();
}
public void onMessage(Message msg) {
try {
BaseTestCase.assertEquals(1, msg.getIntProperty("JMS_JORAM_ERRORCOUNT"));
BaseTestCase.assertEquals(MessageErrorConstants.EXPIRED, msg.getIntProperty("JMS_JORAM_ERRORCODE_1"));
} catch (Exception exc) {
exc.printStackTrace();
}
}
}
/**
......
......@@ -39,6 +39,7 @@ import org.objectweb.joram.client.jms.admin.AdminModule;
import org.objectweb.joram.client.jms.admin.DeadMQueue;
import org.objectweb.joram.client.jms.admin.User;
import org.objectweb.joram.client.jms.tcp.TcpConnectionFactory;
import org.objectweb.joram.shared.MessageErrorConstants;
import fr.dyade.aaa.agent.AgentServer;
......@@ -64,19 +65,23 @@ class MsgList21B implements MessageListener {
nbReceived++;
try {
int index = msg.getIntProperty("Index");
BaseTestCase.assertEquals(msg.getIntProperty("JMS_JORAM_ERRORCOUNT"), 1);
if (index == 0) {
BaseTestCase.assertTrue(msg.getBooleanProperty("JMS_JORAM_UNDELIVERABLE"));
BaseTestCase.assertEquals(msg.getShortProperty("JMS_JORAM_ERRORCODE_1"), MessageErrorConstants.UNDELIVERABLE);
System.out.println("msg#" + index + ", Undeliverable message: "
+ msg.getIntProperty("JMSXDeliveryCount"));
+ msg.getStringProperty("JMS_JORAM_ERRORCAUSE_1"));
} else if (index == 1) {
BaseTestCase.assertTrue(msg.getBooleanProperty("JMS_JORAM_NOTWRITABLE"));
System.out.println("msg#" + index + ", Non writable destination.");
BaseTestCase.assertEquals(msg.getShortProperty("JMS_JORAM_ERRORCODE_1"), MessageErrorConstants.NOT_WRITEABLE);
System.out.println("msg#" + index + ", Non writable destination: "
+ msg.getStringProperty("JMS_JORAM_ERRORCAUSE_1"));
} else if (index == 2) {
BaseTestCase.assertTrue(msg.getBooleanProperty("JMS_JORAM_DELETEDDEST"));
System.out.println("msg#" + index + ", Destination does not exist.");
BaseTestCase.assertEquals(msg.getShortProperty("JMS_JORAM_ERRORCODE_1"), MessageErrorConstants.DELETED_DEST);
System.out.println("msg#" + index + ", Destination does not exist: "
+ msg.getStringProperty("JMS_JORAM_ERRORCAUSE_1"));
} else if (index == 3) {
BaseTestCase.assertTrue(msg.getBooleanProperty("JMS_JORAM_ADMINDELETED"));
System.out.println("msg#" + index + ", An admin has deleted the message.");
BaseTestCase.assertEquals(msg.getShortProperty("JMS_JORAM_ERRORCODE_1"), MessageErrorConstants.ADMIN_DELETED);
System.out.println("msg#" + index + ", An admin has deleted the message: "
+ msg.getStringProperty("JMS_JORAM_ERRORCAUSE_1"));
} else {
BaseTestCase.assertTrue(false);
}
......@@ -110,11 +115,10 @@ public class Test21 extends BaseTest{
AgentServer.start();
Thread.sleep(1000L);
short sid = Integer.getInteger("sid", 0).shortValue();
AdminModule.connect("localhost", 16010, "root", "root", 60);
User user = User.create("anonymous", "anonymous");
User.create("anonymous", "anonymous");
Queue queue1 = Queue.create(0);
Queue queue2 = Queue.create(0);
Queue queue3 = Queue.create(0);
......
......@@ -38,6 +38,7 @@ import org.objectweb.joram.client.jms.admin.AdminModule;
import org.objectweb.joram.client.jms.admin.DeadMQueue;
import org.objectweb.joram.client.jms.admin.User;
import org.objectweb.joram.client.jms.local.LocalConnectionFactory;
import org.objectweb.joram.shared.MessageErrorConstants;
import fr.dyade.aaa.agent.AgentServer;
......@@ -136,13 +137,11 @@ public class Test31 extends joram.framework.TestCase implements MessageListener{
}
}
public synchronized void onMessage(Message msg) {
int index = -1;
public synchronized void onMessage(Message msg) {
try {
assertTrue( msg.getBooleanProperty("JMS_JORAM_EXPIRED"));
assertEquals(1, msg.getIntProperty("JMS_JORAM_ERRORCOUNT"));
assertEquals(MessageErrorConstants.EXPIRED, msg.getIntProperty("JMS_JORAM_ERRORCODE_1"));
} catch (JMSException exc) {
exc.printStackTrace();
}
......
......@@ -34,6 +34,7 @@ import org.objectweb.joram.client.jms.admin.AdminModule;
import org.objectweb.joram.client.jms.admin.DeadMQueue;
import org.objectweb.joram.client.jms.admin.User;
import org.objectweb.joram.client.jms.local.LocalConnectionFactory;
import org.objectweb.joram.shared.MessageErrorConstants;
import fr.dyade.aaa.agent.AgentServer;
......@@ -102,7 +103,10 @@ public class Test46 extends BaseTest {
assertEquals(i,index);
index = msg.getIntProperty("Index");
assertTrue(msg.getBooleanProperty("JMS_JORAM_UNDELIVERABLE"));
assertEquals(1, msg.getIntProperty("JMS_JORAM_ERRORCOUNT"));
assertEquals(MessageErrorConstants.UNDELIVERABLE, msg.getShortProperty("JMS_JORAM_ERRORCODE_1"));
System.out.println("Cause: " + msg.getStringProperty("JMS_JORAM_ERRORCAUSE_1"));
assertEquals(3, msg.getIntProperty("JMSXDeliveryCount"));
//System.out.println("msg#" + index + ", Undeliverable message: " + msg.getIntProperty("JMSXDeliveryCount"));
}
......
......@@ -41,6 +41,7 @@ import org.objectweb.joram.client.jms.admin.AdminModule;
import org.objectweb.joram.client.jms.admin.DeadMQueue;
import org.objectweb.joram.client.jms.admin.User;
import org.objectweb.joram.client.jms.tcp.TcpConnectionFactory;
import org.objectweb.joram.shared.MessageErrorConstants;
/**
......@@ -105,13 +106,9 @@ public class Test2_Queue extends TestCase {
// Check some message properties
msg = (TextMessage) consumerdq1.receive(500);
assertTrue(msg.getBooleanProperty("JMS_JORAM_EXPIRED"));
System.out.println("Expired at: " + msg.getLongProperty("JMS_JORAM_EXPIRATIONDATE"));
assertFalse(msg.getBooleanProperty("JMS_JORAM_NOTWRITABLE"));
assertFalse(msg.getBooleanProperty("JMS_JORAM_UNDELIVERABLE"));
assertFalse(msg.getBooleanProperty("JMS_JORAM_ADMINDELETED"));
assertFalse(msg.getBooleanProperty("JMS_JORAM_DELETEDDEST"));
assertFalse(msg.getBooleanProperty("JMS_JORAM_QUEUEFULL"));
assertEquals(1, msg.getIntProperty("JMS_JORAM_ERRORCOUNT"));
assertEquals(MessageErrorConstants.EXPIRED, msg.getShortProperty("JMS_JORAM_ERRORCODE_1"));
System.out.println("Expired at: " + msg.getStringProperty("JMS_JORAM_ERRORCAUSE_1"));
// the server containing the queue is stopped
stopAgentServer((short) 1);
......@@ -139,13 +136,9 @@ public class Test2_Queue extends TestCase {
// Check some message properties
MessageConsumer consumerdq0 = sessionp.createConsumer(dmqueue0);
msg = (TextMessage) consumerdq0.receive(500);
assertTrue(msg.getBooleanProperty("JMS_JORAM_EXPIRED"));
System.out.println("Expired at: " + msg.getLongProperty("JMS_JORAM_EXPIRATIONDATE"));
assertFalse(msg.getBooleanProperty("JMS_JORAM_NOTWRITABLE"));
assertFalse(msg.getBooleanProperty("JMS_JORAM_UNDELIVERABLE"));
assertFalse(msg.getBooleanProperty("JMS_JORAM_ADMINDELETED"));
assertFalse(msg.getBooleanProperty("JMS_JORAM_DELETEDDEST"));
assertFalse(msg.getBooleanProperty("JMS_JORAM_QUEUEFULL"));
assertEquals(1, msg.getIntProperty("JMS_JORAM_ERRORCOUNT"));
assertEquals(MessageErrorConstants.EXPIRED, msg.getShortProperty("JMS_JORAM_ERRORCODE_1"));
System.out.println("Expired at: " + msg.getStringProperty("JMS_JORAM_ERRORCAUSE_1"));
cnx.close();
cnxCons.close();
......
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