KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > recover > test > RecoveryFromCrashOfSecondRemoteResourceWithXADatabaseAfterPrepareIIOPJBRemTestCase


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.recover.test;
23
24 import javax.naming.Context JavaDoc;
25 import javax.rmi.PortableRemoteObject JavaDoc;
26 import javax.transaction.UserTransaction JavaDoc;
27
28 import junit.framework.Test;
29
30 import org.jboss.test.recover.interfaces.FrontEnd;
31 import org.jboss.test.recover.interfaces.FrontEndHome;
32
33 /**
34  * A RecoveryFromCrashOfSecondRemoteResourceWithXADatabaseAfterPrepareIIOPJBRemTestCase.
35  *
36  * @author <a HREF="reverbel@ime.usp.br">Francisco Reverbel</a>
37  * @version $Revision: 37406 $
38  */

39 public class RecoveryFromCrashOfSecondRemoteResourceWithXADatabaseAfterPrepareIIOPJBRemTestCase
40       extends JBossCrashRecoveryIIOPTestCase
41 {
42    public RecoveryFromCrashOfSecondRemoteResourceWithXADatabaseAfterPrepareIIOPJBRemTestCase(String JavaDoc name)
43    {
44       super(name);
45    }
46    
47    public void test() throws Exception JavaDoc
48    {
49       log.info("*** starting " + getUnqualifiedClassName() + " ***");
50       
51       Context JavaDoc ctx = getInitialContext();
52
53       getLog().debug("Obtain UserTransaction instance");
54       UserTransaction JavaDoc userTx = (UserTransaction JavaDoc) ctx.lookup("UserTransaction");
55    
56       getLog().debug("Obtain home interface");
57       Object JavaDoc objref = ctx.lookup("dtmrecoverytest/FrontEndEJB");
58       FrontEndHome home =
59          (FrontEndHome) PortableRemoteObject.narrow(objref, FrontEndHome.class);
60       
61       getLog().debug("Create FrontEnd bean");
62       FrontEnd frontEnd = home.create("testCommittedTx", true);
63
64       getLog().debug("Check updated balances");
65       userTx.begin();
66       int[] balances = frontEnd.getBalancesOverIIOPAndJBRem();
67       userTx.commit();
68    
69       assertTrue("first balance == 201", balances[0] == 201);
70       assertTrue("second balance == 202", balances[1] == 202);
71    
72       getLog().debug("Remove FrontEnd bean");
73       frontEnd.remove();
74    }
75    
76    public static Test suite() throws Exception JavaDoc
77    {
78       return suite(RecoveryFromCrashOfSecondRemoteResourceWithXADatabaseAfterPrepareIIOPJBRemTestCase.class);
79    }
80
81 }
82
Popular Tags