KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > test > cms > stress > EndTxCommand


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.test.cms.stress;
10
11 import org.jboss.portal.cms.NodeFactory;
12 import org.jboss.portal.common.transaction.Transactions;
13
14 import javax.transaction.TransactionManager JavaDoc;
15
16 /**
17  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
18  * @version $Revision: 1.1 $
19  */

20 public class EndTxCommand extends Command
21 {
22
23    private boolean shouldCommit;
24
25    public EndTxCommand(boolean shouldCommit)
26    {
27       this.shouldCommit = Boolean.valueOf(shouldCommit).booleanValue();
28    }
29
30    public void execute(Client.Result result, NodeFactory factory) throws Exception JavaDoc
31    {
32       TransactionManager JavaDoc tm = factory.getTransactionManager();
33       boolean hasCommited = Transactions.end(tm);
34       result.assertTrue(hasCommited == shouldCommit, hasCommited ? "not rollbacked" : "not commited");
35    }
36
37    protected String JavaDoc describe()
38    {
39       return shouldCommit ? "[commit]" : "[rollback]";
40    }
41
42 }
43
Popular Tags