Commit 6a515288 authored by Andre Freyssinet's avatar Andre Freyssinet
Browse files

Adds tests for JDBC Transaction.

parent f94fd053
# Properties needed to launch an A3 server with JDBC
org.ow2.joram.jdbc.transaction.driver=org.apache.derby.jdbc.EmbeddedDriver
org.ow2.joram.jdbc.transaction.url=jdbc:derby:MyJoramDB@@sid@@;create=true
org.ow2.joram.dbtransaction.dbtable=MyTable
org.ow2.joram.jdbc.transaction.dbname=MyJoramDB@@sid@@
org.ow2.joram.jdbc.transaction.user=user1
org.ow2.joram.jdbc.transaction.password=pass1
org.ow2.joram.jdbc.transaction.dbinit=CREATE TABLE MyTable (name VARCHAR(256), content BLOB(16M), PRIMARY KEY(name))
# Properties needed to launch an A3 server
......@@ -3,6 +3,8 @@
<config>
<property name="Engine" value="@engine@"/>
<property name="Transaction" value="@transaction@"/>
@properties@
<server id="0" name="S0" hostname="localhost">
<service class="fr.dyade.aaa.agent.AdminProxy" args="8090"/>
......
<?xml version="1.0"?>
<config>
<property name="Engine" value="@engine@"/>
<property name="Transaction" value="@transaction@"/>
<domain name="D1" network="@network@"/>
<server id="0" name="S0" hostname="localhost">
<network domain="D1" port="16300"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8090"/>
</server>
<server id="1" name="S1" hostname="localhost">
<network domain="D1" port="16301"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8091"/>
</server>
<server id="2" name="S2" hostname="localhost">
<network domain="D1" port="16302"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8092"/>
</server>
</config>
<?xml version="1.0"?>
<config>
<property name="Engine" value="@engine@"/>
<property name="Transaction" value="@transaction@"/>
<domain name="D1" network="@network@"/>
@properties@
<server id="0" name="S0" hostname="localhost">
<network domain="D1" port="16300"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8090"/>
</server>
<server id="1" name="S1" hostname="localhost">
<network domain="D1" port="16301"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8091"/>
</server>
<server id="2" name="S2" hostname="localhost">
<network domain="D1" port="16302"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8092"/>
</server>
</config>
<?xml version="1.0"?>
<config>
<property name="Engine" value="@engine@"/>
<property name="Transaction" value="@transaction@"/>
<domain name="D1" network="@network@"/>
<server id="0" name="S0" hostname="localhost">
<network domain="D1" port="16300"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8090"/>
</server>
<server id="1" name="S1" hostname="localhost">
<network domain="D1" port="16301"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8091"/>
</server>
</config>
<?xml version="1.0"?>
<config>
<property name="Engine" value="@engine@"/>
<property name="Transaction" value="@transaction@"/>
<domain name="D1" network="@network@"/>
@properties@
<server id="0" name="S0" hostname="localhost">
<network domain="D1" port="16300"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8090"/>
</server>
<server id="1" name="S1" hostname="localhost">
<network domain="D1" port="16301"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8091"/>
</server>
</config>
......@@ -7,6 +7,8 @@
<property name="PoolNetwork.nbMaxCnx" value="@nbMaxCnx@"/>
<property name="PoolNetwork.compressedFlows" value="@compressedFlows@"/>
@properties@
<domain name="D1" network="@network@"/>
<server id="0" name="S0" hostname="localhost">
......
......@@ -9,6 +9,8 @@
<domain name="D1" network="@network@"/>
<domain name="D2" network="@network@"/>
@properties@
<server id="0" name="S0" hostname="localhost">
<network domain="D1" port="16300"/>
......
......@@ -10,6 +10,8 @@
<property name="PoolNetwork.IdleTimeout" value="15"/>
<domain name="D1" network="@network@"/>
@properties@
<server id="0" name="S0" hostname="localhost">
<network domain="D1" port="16300"/>
......
......@@ -11,6 +11,8 @@
<domain name="D1" network="@network@"/>
<domain name="D2" network="@network@"/>
@properties@
<server id="0" name="S0" hostname="localhost">
<network domain="D1" port="16300"/>
......
<?xml version="1.0"?>
<config>
<property name="Engine" value="@engine@"/>
<property name="Transaction" value="@transaction@"/>
<domain name="D1" network="@network@"/>
<domain name="D2" network="@network@"/>
<server id="0" name="S0" hostname="localhost">
<network domain="D1" port="16300"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8090"/>
</server>
<server id="1" name="S1" hostname="localhost">
<network domain="D2" port="16301"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8091"/>
</server>
<server id="2" name="S2" hostname="localhost">
<network domain="D1" port="16302"/>
<network domain="D2" port="16303"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8092"/>
</server>
</config>
<?xml version="1.0"?>
<config>
<property name="Engine" value="@engine@"/>
<property name="Transaction" value="@transaction@"/>
<domain name="D1" network="@network@"/>
<domain name="D2" network="@network@"/>
@properties@
<server id="0" name="S0" hostname="localhost">
<network domain="D1" port="16300"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8090"/>
</server>
<server id="1" name="S1" hostname="localhost">
<network domain="D2" port="16301"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8091"/>
</server>
<server id="2" name="S2" hostname="localhost">
<network domain="D1" port="16302"/>
<network domain="D2" port="16303"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8092"/>
</server>
</config>
<?xml version="1.0"?>
<config>
<domain name="D1" network="fr.dyade.aaa.agent.HttpNetwork"/>
<property name="D1.ActivationPeriod" value="1000"/>
<property name="D1.NbDaemon" value="2"/>
<server id="0" name="S0" hostname="localhost">
<network domain="D1" port="16300"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8090"/>
</server>
<server id="1" name="S1" hostname="localhost">
<network domain="D1" port="0"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8091"/>
</server>
<server id="2" name="S2" hostname="localhost">
<network domain="D1" port="0"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8092"/>
</server>
</config>
<?xml version="1.0"?>
<config>
<domain name="D1" network="fr.dyade.aaa.agent.HttpNetwork"/>
<property name="D1.ActivationPeriod" value="1000"/>
<property name="D1.NbDaemon" value="2"/>
<server id="0" name="S0" hostname="localhost">
<network domain="D1" port="16300"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8090"/>
</server>
<server id="1" name="S1" hostname="localhost">
<network domain="D1" port="0"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8091"/>
</server>
<server id="2" name="S2" hostname="localhost">
<network domain="D1" port="0"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8092"/>
</server>
</config>
<?xml version="1.0"?>
<config>
<domain name="D1" network="fr.dyade.aaa.agent.SimpleNetwork"/>
<domain name="D2" network="fr.dyade.aaa.agent.NGNetwork"/>
<server id="0" name="S0" hostname="localhost">
<network domain="D1" port="16300"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8090"/>
</server>
<server id="1" name="S1" hostname="localhost">
<network domain="D2" port="16301"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8091"/>
</server>
<server id="2" name="S2" hostname="localhost">
<network domain="D1" port="16302"/>
<network domain="D2" port="16303"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8092"/>
</server>
</config>
<?xml version="1.0"?>
<config>
<domain name="D1" network="fr.dyade.aaa.agent.SimpleNetwork"/>
<domain name="D2" network="fr.dyade.aaa.agent.NGNetwork"/>
@properties@
<server id="0" name="S0" hostname="localhost">
<network domain="D1" port="16300"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8090"/>
</server>
<server id="1" name="S1" hostname="localhost">
<network domain="D2" port="16301"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8091"/>
</server>
<server id="2" name="S2" hostname="localhost">
<network domain="D1" port="16302"/>
<network domain="D2" port="16303"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8092"/>
</server>
</config>
<?xml version="1.0"?>
<config>
<domain name="D1"/>
<server id="0" name="S0" hostname="localhost">
<network domain="D1" port="16300"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8090"/>
</server>
<!-- Inexistent server#1 -->
<server id="2" name="S2" hostname="localhost">
<network domain="D1" port="16302"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8092"/>
</server>
</config>
<?xml version="1.0"?>
<config>
<domain name="D1"/>
@properties@
<server id="0" name="S0" hostname="localhost">
<network domain="D1" port="16300"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8090"/>
</server>
<!-- Inexistent server#1 -->
<server id="2" name="S2" hostname="localhost">
<network domain="D1" port="16302"/>
<service class="fr.dyade.aaa.agent.AdminProxy" args="8092"/>
</server>
</config>
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - 2009 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):
*/
package a3.base;
import fr.dyade.aaa.agent.Agent;
import fr.dyade.aaa.agent.AgentId;
import fr.dyade.aaa.agent.Notification;
import framework.TestCase;
public class test14 extends TestCase {
public test14() {
super();
}
protected void setUp() throws Exception {
timeout = 15000L;
startAgentServer((short) 1, new String[] { "-DTransaction.UseLockFile=false" });
Test14Master master = new Test14Master();
Test14Slave slave = new Test14Slave((short) 1);
master.slave = slave.getId();
slave.master = master.getId();
master.deploy();
slave.deploy();
}
protected void tearDown() {
killAgentServer((short) 1);
}
public static void main(String args[]) {
new test14().runTest(args);
}
static class Test14Not extends Notification {
boolean creation;
Test14Not(boolean creation) {
this.creation = creation;
}
}
static class Test14Master extends Agent {
int state = 0;
AgentId slave;
public Test14Master() {
super();
}
public void react(AgentId from, Notification not) {
try {
switch (state) {
case 0:
TestCase.assertEquals(from, slave);
TestCase.assertEquals(not.getClass().getName(),
"a3.base.test14$Test14Not");
TestCase.assertTrue(((Test14Not) not).creation);
// Stop, then start AgentServer#1
killAgentServer((short) 1);
startAgentServer((short) 1, new String[] { "-DTransaction.UseLockFile=false" });
// Then send a not to slave in order to reload it !!
sendTo(slave, new Notification());
break;
case 1:
TestCase.assertEquals(from, slave);
TestCase.assertEquals(not.getClass().getName(),
"a3.base.test14$Test14Not");
TestCase.assertFalse(((Test14Not) not).creation);
TestCase.endTest();
// never reached
}
state += 1;
} catch (Exception exc) {
TestCase.error(exc);
TestCase.endTest();
}
}
}
static class Test14Slave extends Agent {
AgentId master;
public Test14Slave(short to) {
super(to);
}
public void agentInitialize(boolean creation) {
sendTo(master, new Test14Not(creation));
}
public void react(AgentId from, Notification not) {
}
}
}
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - 2009 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):
*/
package a3.base;
import fr.dyade.aaa.agent.Agent;
import fr.dyade.aaa.agent.AgentId;
import fr.dyade.aaa.agent.Notification;
import framework.TestCase;
public class test14 extends TestCase {
public test14() {
super();
}
protected void setUp() throws Exception {
timeout = 30000L;
startAgentServer((short) 1, new String[] { "-DTransaction.UseLockFile=false" });
Test14Master master = new Test14Master();
Test14Slave slave = new Test14Slave((short) 1);
master.slave = slave.getId();
slave.master = master.getId();
master.deploy();
slave.deploy();
}
protected void tearDown() {
killAgentServer((short) 1);
}
public static void main(String args[]) {
new test14().runTest(args);
}
static class Test14Not extends Notification {
boolean creation;
Test14Not(boolean creation) {
this.creation = creation;
}
}
static class Test14Master extends Agent {
int state = 0;
AgentId slave;
public Test14Master() {
super();
}
public void react(AgentId from, Notification not) {
try {
switch (state) {
case 0:
TestCase.assertEquals(from, slave);
TestCase.assertEquals(not.getClass().getName(),
"a3.base.test14$Test14Not");
TestCase.assertTrue(((Test14Not) not).creation);
// Stop, then start AgentServer#1
killAgentServer((short) 1);
startAgentServer((short) 1, new String[] { "-DTransaction.UseLockFile=false" });
// Then send a not to slave in order to reload it !!
sendTo(slave, new Notification());
break;
case 1:
TestCase.assertEquals(from, slave);
TestCase.assertEquals(not.getClass().getName(),
"a3.base.test14$Test14Not");
TestCase.assertFalse(((Test14Not) not).creation);
TestCase.endTest();
// never reached
}
state += 1;
} catch (Exception exc) {
TestCase.error(exc);
TestCase.endTest();
}
}
}
static class Test14Slave extends Agent {
AgentId master;
public Test14Slave(short to) {
super(to);
}
public void agentInitialize(boolean creation) {
sendTo(master, new Test14Not(creation));
}
public void react(AgentId from, Notification not) {
}
}
}
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 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):
*/
package a3.base;
import fr.dyade.aaa.agent.Agent;
import fr.dyade.aaa.agent.AgentId;
import fr.dyade.aaa.agent.Channel;
import fr.dyade.aaa.agent.Notification;
import framework.TestCase;
public class test15 extends TestCase {
public test15() {
super();
}
short ServerEcho = (short) 0;
protected void setUp() throws Exception {
timeout = 60000L;
ServerEcho = Integer.getInteger("Echo", ServerEcho).shortValue();
if (ServerEcho != 0)
startAgentServer((short) ServerEcho);
Echo echo = new Echo((short) ServerEcho);
echo.deploy();
Test agent = new Test(echo.getId());
agent.deploy();
// this notification should be destroyed at post (Engine or Network).
Ball not = new Ball(0);
not.setExpiration(System.currentTimeMillis()-1000L);
Channel.sendTo(agent.getId(), not);
// this notification should be handled.
not = new Ball(1);
not.setExpiration(System.currentTimeMillis()+1000L);
Channel.sendTo(agent.getId(), not);