FileDocCategorySizeDatePackage
Test.javaAPI DocExample3235Thu Nov 08 00:22:48 GMT 2001com.ora.rmibook.chapter13.bank.applications

Test

public abstract class Test extends Object implements Comparable

Fields Summary
public static final String
UNABLE_TO_CONNECT
public static final String
ACCOUNT_WAS_LOCKED
public static final String
REMOTE_EXCEPTION_THROWN
public static final String
FAILURE
public static final String
SUCCESS
public String
status
public long
duration
public long
startTime
public String
accountName
private NameRepository
_nameRepository
private String
_className
Constructors Summary
public Test(NameRepository nameRepository)


          

       

       
        _nameRepository = nameRepository;
        _className = getClass().getName();
    
Methods Summary
public intcompareTo(java.lang.Object object)

        // first sort is alphabetical, on class name.
        // second test is on account name
        // third test is by startTime.
        // fourth test uses hashcode

        Test otherTest = (Test) object;
        String otherClassName = (otherTest.getClass()).getName();
        int firstTest = _className.compareTo(otherClassName);

        if (0 != firstTest) {
            return firstTest;
        }
        int secondTest = accountName.compareTo(otherTest.accountName);

        if (0 != secondTest) {
            return secondTest;
        }
        if (startTime < otherTest.startTime) {
            return -1;
        } else {
            if (startTime > otherTest.startTime) {
                return +1;
            }
        }
        return hashCode() - otherTest.hashCode();
    
protected abstract java.lang.StringdescribeOperation()

public java.lang.StringdescribeOutcome()

        return "Attempted to " + describeOperation() + " account " + accountName
            + " at " + startTime + ". \n\t The operation took " + duration 
            + " milliseconds and the result was : " + status + "\n";
    
private Account3getAccount()

        accountName = _nameRepository.getAName();
        Account3 account = null;;
        try {
            account = (Account3) Naming.lookup(accountName);
        } catch (Exception e) {
        }
        return account;
    
protected MoneygetRandomMoney()


        /*
         Sometimes the money will be negative. But,
         most of the time, we'll send in positive amounts.
         */
        int cents = -2000 + (int) (Math.random() * 100000);

        return new Money(cents);
    
protected abstract java.lang.StringperformActualTest(java.lang.String idNumber, Account3 account)

public voidperformTest(java.lang.String idNumber)

        Account3 account = getAccount();

        if (null == account) {
            status = UNABLE_TO_CONNECT;
            duration = 0;
            return;
        }
        startTime = System.currentTimeMillis();
        status = performActualTest(idNumber, account);
        duration = System.currentTimeMillis() - startTime;
        return;