Nitesh Varma wrote:
>
> Hello,
>
> I've two beans, Publisher (session) and Document (entity), and I'm doing
> some tests with transaction. Publisher bean has only one method:
> publish(Document, DocInfo) which has transaction attribute of "Supports".
> Document bean has three setter methods (transaction attribute "Mandatory")
> and three getter methods (transaction attribute "Required"). I'm using
> Jonas 2.3.
>
> In my JUnit test, I'm doing the following:
>
> public void testTxPropagationRollback() {
> try {
> publisher.publish(doc, docInfo); // this should fail, but doesn't
> assertEquals(doc.getAuthor().trim(), docInfo.author);
> assertEquals(doc.getTitle().trim(), docInfo.title);
> assertEquals(doc.getISBN().trim(), docInfo.isbn);
>
> tx =
> (UserTransaction)ctx.lookup("javax.transaction.UserTransaction");
> tx.begin();
> assertEquals(javax.transaction.Status.STATUS_ACTIVE,
> tx.getStatus());
> doc.setAuthor("Varma Nitesh"); // this should succeed, but doesn't
> tx.rollback();
>
> assertEquals(docInfo.author, doc.getAuthor());
>
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
>
> The Publisher.publish(Document, DocInfo) method does the following:
>
> public void publish(Document doc, DocumentInfo docInfo) {
> try {
> doc.setAuthor(docInfo.author);
> doc.setTitle(docInfo.title);
> doc.setISBN(docInfo.isbn);
> } catch (RemoteException e) {
> e.printStackTrace();
> }
> }
>
> My problems:
> 1. I expect that calling the publish method in the test client without using
> a transaction should fail. But it succeeds!
> 2. When I call a method on Document within a UserTransaction, I get a
> javax.transaction.TransactionRequired exception. It should succeed because
> I already started a UserTransaction.
>
> Any pointers as to what may be going on?
I agree with you that all this is not clear. 1. should fail and 2.
should work. Can you send me your deployment descriptor to check if all
is OK with it ?
Thanks.
>
> Thanks for your help in advance.
>
> Nitesh
> ----
> To unsubscribe, send email to [EMAIL PROTECTED] and
> include in the body of the message "unsubscribe jonas-users".
> For general help, send email to [EMAIL PROTECTED] and
> include in the body of the message "help".
--
Philippe Durieux ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Bull - 1 rue de Provence - 38432 Echirolles Cedex France
[EMAIL PROTECTED]
-> Download our EJBServer at http://www.evidian.com/ejb <-
----
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe jonas-users".
For general help, send email to [EMAIL PROTECTED] and
include in the body of the message "help".