Commit 44c96773 authored by Guillaume Surrel's avatar Guillaume Surrel

Adds ChainedDMQ test.

parent 2a1193dc
......@@ -65,7 +65,7 @@
<ant dir="." antfile="build.xml" target="base.test_T_MMap"/>
<ant dir="." antfile="build.xml" target="base.test_Q_MStream"/>
<ant dir="." antfile="build.xml" target="base.test_T_MStream"/>
<ant dir="." antfile="build.xml" target="base.test_dmqb"/>
<ant dir="." antfile="build.xml" target="base.test_DMQ_Body"/>
</target>
<target name="tests.property"
......@@ -313,18 +313,19 @@ description=" --> launch all exceptionlistener tests">
<target name="tests.dmq"
description=" --> launch all dmq tests">
<ant dir="." antfile="build.xml" target="dmq.test1"/>
<ant dir="." antfile="build.xml" target="dmq.test2"/>
<ant dir="." antfile="build.xml" target="dmq.test3"/>
<ant dir="." antfile="build.xml" target="dmq.test4"/>
<ant dir="." antfile="build.xml" target="dmq.test5"/>
<ant dir="." antfile="build.xml" target="dmq.test6"/>
<ant dir="." antfile="build.xml" target="dmq.TestDmq1"/>
<ant dir="." antfile="build.xml" target="dmq.TestDmq2"/>
<ant dir="." antfile="build.xml" target="dmq.TestDmq3"/>
<ant dir="." antfile="build.xml" target="dmq.TestDmq4"/>
<ant dir="." antfile="build.xml" target="dmq.TestDmq5"/>
<ant dir="." antfile="build.xml" target="dmq.TestDmq6"/>
<ant dir="." antfile="build.xml" target="dmq.ChainedDMQ"/>
</target>
<target name="tests.ttl"
description=" --> launch all ttl tests">
<ant dir="." antfile="build.xml" target="ttl.test1"/>
<ant dir="." antfile="build.xml" target="ttl.test2"/>
<ant dir="." antfile="build.xml" target="ttl.Test1_Topic"/>
<ant dir="." antfile="build.xml" target="ttl.Test2_Queue"/>
</target>
<target name="tests.sub"
......@@ -646,7 +647,7 @@ description=" --> launch all exceptionlistener tests">
</antcall>
</target>
<target name="base.test_dmqb" depends="init.a3props,compile"
<target name="base.test_DMQ_Body" depends="init.a3props,compile"
description=" --> test that a message body is not delete on a Dqueue when restart server">
<antcall target="test.run" inheritAll="true">
<param name="transaction" value="fr.dyade.aaa.util.NullTransaction"/>
......@@ -2627,6 +2628,7 @@ description=" --> launch all exceptionlistener tests">
<param name="a3conf" value="noreg/a3servers1.xml"/>
<param name="engine" value="fr.dyade.aaa.agent.Engine"/>
<param name="transaction" value="fr.dyade.aaa.util.NTransaction"/>
<param name="testid" value="1"/>
<param name="jvmargs" value="-DDestination=org.objectweb.joram.client.jms.Topic -DBaseClass=joram.noreg.TcpBaseTest"/>
</antcall>
</target>
......@@ -2637,6 +2639,7 @@ description=" --> launch all exceptionlistener tests">
<param name="a3conf" value="noreg/a3servers1.xml"/>
<param name="engine" value="fr.dyade.aaa.agent.Engine"/>
<param name="transaction" value="fr.dyade.aaa.util.NTransaction"/>
<param name="testid" value="2"/>
<param name="jvmargs" value="-DDestination=org.objectweb.joram.client.jms.Queue -DBaseClass=joram.noreg.TcpBaseTest"/>
</antcall>
</target>
......@@ -2647,6 +2650,7 @@ description=" --> launch all exceptionlistener tests">
<param name="a3conf" value="noreg/a3servers1.xml"/>
<param name="engine" value="fr.dyade.aaa.agent.Engine"/>
<param name="transaction" value="fr.dyade.aaa.util.NTransaction"/>
<param name="testid" value="3"/>
<param name="jvmargs" value="-DDestination=org.objectweb.joram.client.jms.Topic -DBaseClass=joram.noreg.ColocatedBaseTest"/>
</antcall>
</target>
......@@ -2657,6 +2661,7 @@ description=" --> launch all exceptionlistener tests">
<param name="a3conf" value="noreg/a3servers1.xml"/>
<param name="engine" value="fr.dyade.aaa.agent.Engine"/>
<param name="transaction" value="fr.dyade.aaa.util.NTransaction"/>
<param name="testid" value="4"/>
<param name="jvmargs" value="-DDestination=org.objectweb.joram.client.jms.Queue -DBaseClass=joram.noreg.ColocatedBaseTest"/>
</antcall>
</target>
......@@ -2677,6 +2682,7 @@ description=" --> launch all exceptionlistener tests">
<param name="a3conf" value="noreg/a3servers1.xml"/>
<param name="engine" value="fr.dyade.aaa.agent.Engine"/>
<param name="transaction" value="fr.dyade.aaa.util.NTransaction"/>
<param name="testid" value="1"/>
<param name="jvmargs" value="-DDestination=org.objectweb.joram.client.jms.Topic -DBaseClass=joram.noreg.TcpBaseTest"/>
</antcall>
</target>
......@@ -2687,6 +2693,7 @@ description=" --> launch all exceptionlistener tests">
<param name="a3conf" value="noreg/a3servers1.xml"/>
<param name="engine" value="fr.dyade.aaa.agent.Engine"/>
<param name="transaction" value="fr.dyade.aaa.util.NTransaction"/>
<param name="testid" value="2"/>
<param name="jvmargs" value="-DDestination=org.objectweb.joram.client.jms.Queue -DBaseClass=joram.noreg.TcpBaseTest"/>
</antcall>
</target>
......@@ -2697,6 +2704,7 @@ description=" --> launch all exceptionlistener tests">
<param name="a3conf" value="noreg/a3servers1.xml"/>
<param name="engine" value="fr.dyade.aaa.agent.Engine"/>
<param name="transaction" value="fr.dyade.aaa.util.NTransaction"/>
<param name="testid" value="3"/>
<param name="jvmargs" value="-DDestination=org.objectweb.joram.client.jms.Topic -DBaseClass=joram.noreg.ColocatedBaseTest"/>
</antcall>
</target>
......@@ -2707,6 +2715,7 @@ description=" --> launch all exceptionlistener tests">
<param name="a3conf" value="noreg/a3servers1.xml"/>
<param name="engine" value="fr.dyade.aaa.agent.Engine"/>
<param name="transaction" value="fr.dyade.aaa.util.NTransaction"/>
<param name="testid" value="4"/>
<param name="jvmargs" value="-DDestination=org.objectweb.joram.client.jms.Queue -DBaseClass=joram.noreg.ColocatedBaseTest"/>
</antcall>
</target>
......@@ -3532,7 +3541,7 @@ description=" --> launch all exceptionlistener tests">
</target>
<!-- start dmq tests -->
<target name="dmq.test1" depends="init.a3props,compile"
<target name="dmq.TestDmq1" depends="init.a3props,compile"
description=" --> check threshold of specigik queue and user">
<antcall target="test.run" inheritAll="true">
<param name="transaction" value="fr.dyade.aaa.util.NullTransaction"/>
......@@ -3543,7 +3552,7 @@ description=" --> launch all exceptionlistener tests">
<param name="args" value=""/>
</antcall>
</target>
<target name="dmq.test2" depends="init.a3props,compile"
<target name="dmq.TestDmq2" depends="init.a3props,compile"
description=" --> check default threshold">
<antcall target="test.run" inheritAll="true">
<param name="transaction" value="fr.dyade.aaa.util.NullTransaction"/>
......@@ -3554,7 +3563,7 @@ description=" --> launch all exceptionlistener tests">
<param name="args" value=""/>
</antcall>
</target>
<target name="dmq.test3" depends="init.a3props,compile"
<target name="dmq.TestDmq3" depends="init.a3props,compile"
description=" --> check default dmq">
<antcall target="test.run" inheritAll="true">
<param name="transaction" value="fr.dyade.aaa.util.NullTransaction"/>
......@@ -3565,7 +3574,7 @@ description=" --> launch all exceptionlistener tests">
<param name="args" value=""/>
</antcall>
</target>
<target name="dmq.test4" depends="init.a3props,compile"
<target name="dmq.TestDmq4" depends="init.a3props,compile"
description=" --> check default dmq and default threshold for queue">
<antcall target="test.run" inheritAll="true">
<param name="transaction" value="fr.dyade.aaa.util.NullTransaction"/>
......@@ -3577,7 +3586,7 @@ description=" --> launch all exceptionlistener tests">
</antcall>
</target>
<target name="dmq.test5" depends="init.a3props,compile"
<target name="dmq.TestDmq5" depends="init.a3props,compile"
description=" --> check default dmq and default threshold for user">
<antcall target="test.run" inheritAll="true">
<param name="transaction" value="fr.dyade.aaa.util.NullTransaction"/>
......@@ -3589,7 +3598,7 @@ description=" --> launch all exceptionlistener tests">
</antcall>
</target>
<target name="dmq.test6" depends="init.a3props,compile"
<target name="dmq.TestDmq6" depends="init.a3props,compile"
description=" --> check config dmq with joramAdmin.xml">
<parallel>
<antcall target="test.run" inheritAll="true">
......@@ -3612,11 +3621,23 @@ description=" --> launch all exceptionlistener tests">
</sequential>
</parallel>
</target>
<target name="dmq.ChainedDMQ" depends="init.a3props,compile"
description=" --> test chaining dmqs">
<antcall target="test.run" inheritAll="true">
<param name="transaction" value="fr.dyade.aaa.util.NullTransaction"/>
<param name="className" value="joram.dmq.ChainedDMQ"/>
<param name="jndiconf" value="dmq/jndi.properties"/>
<param name="a3conf" value="dmq/a3servers.xml"/>
<param name="jvmargs" value=""/>
<param name="args" value=""/>
</antcall>
</target>
<!-- end DMQ tests -->
<!-- TTL tests -->
<target name="ttl.test1" depends="init.a3props,compile"
<target name="ttl.Test1_Topic" depends="init.a3props,compile"
description=" --> test ttl with with 2 distributed serveurs and a topic">
<antcall target="test.run" inheritAll="true">
<param name="transaction" value="fr.dyade.aaa.util.NullTransaction"/>
......@@ -3628,7 +3649,7 @@ description=" --> launch all exceptionlistener tests">
</antcall>
</target>
<target name="ttl.test2" depends="init.a3props,compile"
<target name="ttl.Test2_Queue" depends="init.a3props,compile"
description=" --> test ttl with with 2 distributed serveurs and a queue">
<antcall target="test.run" inheritAll="true">
<param name="transaction" value="fr.dyade.aaa.util.NullTransaction"/>
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2004 - 2007 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
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): (ScalAgent D.T.)
* Contributor(s): Badolle Fabien (ScalAgent D.T.)
*/
package joram.dmq;
import java.util.Properties;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
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;
/**
* Some messages with a TTL are sent to a queue. When they are expired, they go
* to the dmqueue0. When the dmqueue0 is full, the additional messages go to
* dmqueue1. When the dmqueue1 is full, the additional messages go to dmqueue2,
* and so on.
*/
public class ChainedDMQ extends TestCase {
private static int NB_MESSAGES = 75;
private static int DMQ0_MAX_SIZE = 10;
private static int DMQ1_MAX_SIZE = 10;
private static int DMQ2_MAX_SIZE = 10;
private static int DMQ3_MAX_SIZE = 10;
private static int DMQ4_MAX_SIZE = 10;
public static void main(String[] args) {
new ChainedDMQ().run();
}
public void run() {
try {
System.out.println("servers start");
startAgentServer((short) 0);
admin();
System.out.println("admin config ok");
Context ictx = new InitialContext();
Queue queue = (Queue) ictx.lookup("queue");
DeadMQueue dmqueue0 = (DeadMQueue) ictx.lookup("dmqueue0");
DeadMQueue dmqueue1 = (DeadMQueue) ictx.lookup("dmqueue1");
DeadMQueue dmqueue2 = (DeadMQueue) ictx.lookup("dmqueue2");
DeadMQueue dmqueue3 = (DeadMQueue) ictx.lookup("dmqueue3");
DeadMQueue dmqueue4 = (DeadMQueue) ictx.lookup("dmqueue4");
DeadMQueue dmqueue5 = (DeadMQueue) ictx.lookup("dmqueue5");
ConnectionFactory cf0 = (ConnectionFactory) ictx.lookup("cf0");
ictx.close();
Connection cnx = cf0.createConnection();
Session session = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE);
cnx.start();
MessageConsumer consumer = session.createConsumer(queue);
MessageProducer producer = session.createProducer(queue);
TextMessage msg = null;
TextMessage msg1 = null;
for (int j = 0; j < NB_MESSAGES; j++) {
msg = session.createTextMessage();
msg.setText("messagedist#" + j);
producer.send(msg, Message.DEFAULT_DELIVERY_MODE, Message.DEFAULT_PRIORITY, 1000);
}
// Waiting for the messages to be out of date
Thread.sleep(2000);
msg1 = (TextMessage) consumer.receive(500);
assertEquals(null, msg1);
// Messages should be present on the DMQ
AdminModule.connect("localhost", 2560, "root", "root", 60);
assertEquals(DMQ0_MAX_SIZE, dmqueue0.getPendingMessages());
assertEquals(DMQ1_MAX_SIZE, dmqueue1.getPendingMessages());
assertEquals(DMQ2_MAX_SIZE, dmqueue2.getPendingMessages());
assertEquals(DMQ3_MAX_SIZE, dmqueue3.getPendingMessages());
assertEquals(DMQ4_MAX_SIZE, dmqueue4.getPendingMessages());
assertEquals(NB_MESSAGES - DMQ0_MAX_SIZE - DMQ1_MAX_SIZE - DMQ2_MAX_SIZE - DMQ3_MAX_SIZE
- DMQ4_MAX_SIZE, dmqueue5.getPendingMessages());
AdminModule.disconnect();
// 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"));
// 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"));
} catch (Throwable exc) {
exc.printStackTrace();
error(exc);
} finally {
System.out.println("Servers stop ");
stopAgentServer((short) 0);
endTest();
}
}
/**
* Admin : Create queue and a user anonymous use jndi
*/
public void admin() throws Exception {
Properties prop = new Properties();
prop.setProperty("period", "1000");
// connection
AdminModule.connect("localhost", 2560, "root", "root", 60);
// create a Queue
org.objectweb.joram.client.jms.Queue queue = org.objectweb.joram.client.jms.Queue.create(0, prop);
// create a DMQueue
DeadMQueue dmqueue0 = (DeadMQueue) DeadMQueue.create(0);
DeadMQueue dmqueue1 = (DeadMQueue) DeadMQueue.create(0);
DeadMQueue dmqueue2 = (DeadMQueue) DeadMQueue.create(0);
DeadMQueue dmqueue3 = (DeadMQueue) DeadMQueue.create(0);
DeadMQueue dmqueue4 = (DeadMQueue) DeadMQueue.create(0);
DeadMQueue dmqueue5 = (DeadMQueue) DeadMQueue.create(0);
dmqueue0.setNbMaxMsg(DMQ0_MAX_SIZE);
dmqueue1.setNbMaxMsg(DMQ1_MAX_SIZE);
dmqueue2.setNbMaxMsg(DMQ2_MAX_SIZE);
dmqueue3.setNbMaxMsg(DMQ3_MAX_SIZE);
dmqueue4.setNbMaxMsg(DMQ4_MAX_SIZE);
dmqueue0.setDMQ(dmqueue1);
dmqueue1.setDMQ(dmqueue2);
dmqueue2.setDMQ(dmqueue3);
dmqueue3.setDMQ(dmqueue4);
dmqueue4.setDMQ(dmqueue5);
// create a user
org.objectweb.joram.client.jms.admin.User.create("anonymous", "anonymous", 0);
// set permissions
queue.setFreeReading();
queue.setFreeWriting();
dmqueue0.setFreeReading();
dmqueue3.setFreeReading();
queue.setDMQ(dmqueue0);
ConnectionFactory cf0 = TcpConnectionFactory.create("localhost", 2560);
javax.naming.Context jndiCtx = new javax.naming.InitialContext();
jndiCtx.bind("cf0", cf0);
jndiCtx.bind("queue", queue);
jndiCtx.bind("dmqueue0", dmqueue0);
jndiCtx.bind("dmqueue1", dmqueue1);
jndiCtx.bind("dmqueue2", dmqueue2);
jndiCtx.bind("dmqueue3", dmqueue3);
jndiCtx.bind("dmqueue4", dmqueue4);
jndiCtx.bind("dmqueue5", dmqueue5);
jndiCtx.close();
AdminModule.disconnect();
}
}
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