/*
 * JBoss, Home of Professional Open Source
 * Copyright 2006, Red Hat Middleware LLC, and individual contributors 
 * as indicated by the @author tags. 
 * See the copyright.txt in the distribution for a
 * full listing of individual contributors. 
 * This copyrighted material is made available to anyone wishing to use,
 * modify, copy, or redistribute it subject to the terms and conditions
 * of the GNU Lesser General Public License, v. 2.1.
 * This program is distributed in the hope that it will be useful, but WITHOUT A 
 * 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,
 * v.2.1 along with this distribution; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
 * MA  02110-1301, USA.
 * 
 * (C) 2005-2006,
 * @author JBoss Inc.
 */
/*
 * Copyright (C) 2004,
 *
 * Arjuna Technologies Ltd,
 * Newcastle upon Tyne,
 * Tyne and Wear,
 * UK.  
 *
 * $Id: xidcheck.java 2342 2006-03-30 13:06:17Z  $
 */

package com.hp.mwtests.ts.jts.orbspecific.recovery;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import com.arjuna.ats.arjuna.common.arjPropertyManager;
import com.arjuna.orbportability.ORBInfo;
import com.arjuna.orbportability.ORBType;
import com.arjuna.orbportability.common.opPropertyManager;
import org.junit.Test;
import org.omg.CosTransactions.RecoveryCoordinator;

import com.arjuna.ats.arjuna.common.Uid;
import com.arjuna.ats.internal.jts.orbspecific.jacorb.recoverycoordinators.JacOrbRCManager;
import com.arjuna.ats.internal.jts.orbspecific.jacorb.recoverycoordinators.JacOrbRCServiceInit;
import com.arjuna.ats.internal.jts.orbspecific.jacorb.recoverycoordinators.JacOrbRCShutdown;
import com.arjuna.ats.internal.jts.orbspecific.jacorb.recoverycoordinators.JacOrbRecoveryInit;
import com.arjuna.ats.internal.jts.orbspecific.jacorb.recoverycoordinators.RecoverIOR;
import com.hp.mwtests.ts.jts.resources.TestBase;

public class JacORBRecoveryUnitTest extends TestBase
{
    @Test
    public void testORBRCManager () throws Exception
    {
        JacOrbRCManager manager = new JacOrbRCManager();
        RecoveryCoordinator rc = manager.makeRC(new Uid(), new Uid(), new Uid(), false);
        
        assertTrue(rc == null);
        
        manager.destroy(rc);
        manager.destroyAll(null);
    }
    
    @Test
    public void testORBRCShutdown () throws Exception
    {
        JacOrbRCShutdown shutdown = new JacOrbRCShutdown();
        
        shutdown.work();
    }
    
    @Test
    public void testInit () throws Exception
    {
        JacOrbRCServiceInit init = new JacOrbRCServiceInit();
        
        assertFalse(init.startRCservice());
        
        JacOrbRCServiceInit.shutdownRCService();
        
        assertTrue(JacOrbRCServiceInit.type() != null);
    }
    
    @Test
    public void testRecoveryInit () throws Exception
    {
        JacOrbRCServiceInit init = new JacOrbRCServiceInit();
        
        assertFalse(init.startRCservice());
        
        JacOrbRecoveryInit rinit = new JacOrbRecoveryInit();
        
        JacOrbRCServiceInit.shutdownRCService();
    }
    
    @Test
    public void testRecoverIOR () throws Exception
    {
        if (ORBInfo.getOrbEnumValue() != ORBType.JACORB)
            return;

        RecoverIOR ior = new RecoverIOR();

        try
        {
            String iorString = RecoverIOR.newObjectKey("foo", "bar");
            
            RecoverIOR.printIORinfo(iorString);
            
            assertTrue(iorString != null);
        }
        catch (final Exception ex)
        {
        }
    }
}

@@ -1285,16 +1285,53 @@
 ertTrue;
+%0Aimport static org.junit.Assert.fail;
 %0A%0Aimport
@@ -1372,32 +1372,107 @@
 ropertyManager;%0A
+import com.arjuna.orbportability.OA;%0Aimport com.arjuna.orbportability.ORB;%0A
 import com.arjun
@@ -1539,16 +1539,57 @@
 RBType;%0A
+import com.arjuna.orbportability.RootOA;%0A
 import c
@@ -1715,16 +1715,16 @@
 nator;%0A%0A
-
 import c
@@ -1756,16 +1756,63 @@
 on.Uid;%0A
+import com.arjuna.ats.internal.jts.ORBManager;%0A
 import c
@@ -3558,16 +3558,20 @@
 coverIOR
+Fail
  () thro
@@ -3710,16 +3710,55 @@
 rIOR();%0A
+        String iorString = %22%22;%0A        
 %0A       
@@ -3776,39 +3776,32 @@
   %7B%0A            
-String 
 iorString = Reco
@@ -3834,29 +3834,164 @@
  %22bar%22);
-%0A            
+  // no ORB so should fail!%0A            %0A            fail();%0A        %7D%0A        catch (final Exception ex)%0A        %7B%0A        %7D%0A%0A        try%0A        %7B
 %0A       
@@ -4060,36 +4060,13 @@
     
-assertTrue(iorString != null
+fail(
 );%0A 
@@ -4125,20 +4125,66 @@
 %7B%0A        %7D%0A
+        %0A        assertTrue(iorString == %22%22);%0A
     %7D%0A%7D%0A

Make explicit that testing for failure conditions.