OpenCard  
 
OCF, the OpenCard Framework is a standard Java framework for working with Smart Cards.  
 

opencard.tests.terminal
Class WaitForCard

java.lang.Object
  |
  +--opencard.core.service.CardService
        |
        +--opencard.tests.terminal.TestBean
              |
              +--opencard.tests.terminal.WaitForCard

public class WaitForCard
extends TestBean
implements CTListener

The WaitForCard retrieves SmartCard objects from defined Slots. The number of expected smartCards and the number of slot expecting a card can be specified. This Bean is derived from the TestBean which provides most of the required functionality.
There is a list containing all known Slots. This static array is retrieved from the CardTerminalRegistry. There are two vector defined: One containing a "To-Do-Líst" with references to all Slots which still require a smartcard to be inserted. The other vector is a result list containing all valid smartcard objects obtained until now. Additional a maximum number of required smartcards can be specified too (e.g. it is possible to require 3 card from 5 connected terminals).
It is possible to define for this bean under which conditions the wait-request should besatisfied:

setNumberOfCards(no) defines how many smartcards are expected in total; setAllSlotsRequired(); requires smartcards in all slots connected to the sytem. setNumberOfCards is set implicit to the number of connected slots.

setAnySlotRequired(); requires at least one smartcard to be inserted in any of the slots connected to the sytem. setNumberOfCards is set implicit to 1.

setOneSlotRequired(); requires at least one smartcard to be inserted in the slot given by the index. The index refers to a array, which buffers all slots connected to the system.
The Array is static and is retrieved only once from the CardTerminalRegistry.

setNumberOfCards is set implicit to 1.

setNextSlotRequired(); requires one smartcard inserted in that slot which follows the slot last used by a prior waitForCard-Bean. The index of the last slot used is buffered by a static variable. If no waitForCard-Bean was used before, the slot listed first in the Vector of the WaitForCard-Bean is used.
setNumberOfCards is set implicit to 1.

setOneSlotRequired(Slot slot); requires at least one smartcard to be inserted in the slots given by the parameter.
setNumberOfCards is set implicit to 1.

setDefinedSlotsRequired(Slot[] slots); requires at least one smartcard to be inserted im each of the slots defined by the given array.

setNumberOfCards is set implicit to slots.length.

SAMPLE:
WaitForCard wfc = new WaitForCard();
wfc.setId("CTnTest1a");
//wfc.setAllSlotsRequired();
//wfc.setAnySlotRequired();
wfc.setNextSlotRequired();
//wfc.setOneSlotRequired(0);
wfc.addExpectedResult(0);
wfc.execute();
SmartCard[] cards = wfc.getSmartCardArray();

Version:
$Id: WaitForCard.java,v 1.1 1999/12/03 09:31:37 damke Exp $
See Also:
TestBean

Field Summary
protected static int last_used_slot
           
 
Fields inherited from class opencard.tests.terminal.TestBean
resultLookup
 
Constructor Summary
WaitForCard()
          Default constructor.
 
Method Summary
 void cardInserted(CardTerminalEvent ctEvent)
          Gets invoked if a card is inserted.
 void cardRemoved(CardTerminalEvent ctEvent)
          Gets invoked if a card is removed.
 void execute()
          Execute using a previously defined CardTerminal
static Slot[] getAllSlots()
           
protected  int getNumberOfCards()
           
 SmartCard[] getSmartCardArray()
           
 void setAllSlotsRequired()
          Set the execution mode.
 void setAnySlotRequired()
           
 void setDefinedSlotsRequired(Slot[] slots)
           
 void setNextSlotRequired()
           
 void setNumberOfCards(int no)
           
 void setOneSlotRequired(int index)
           
 void setOneSlotRequired(Slot slot)
           
 java.lang.String toString()
           
 
Methods inherited from class opencard.tests.terminal.TestBean
addExpectedResult, addExpectedResult, addUnexpectedResult, addUnexpectedResult, checkResult, clearResultLookup, getId, getLabel, getResult, getResultString, getTitle, isDetails, lookupResult, lookupResult, setDetails, setId, setLabel, setResult, setResult, setResult
 
Methods inherited from class opencard.core.service.CardService
allocateCardChannel, getCard, getCardChannel, getCHVDialog, initialize, releaseCardChannel, setCardChannel, setCHVDialog
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

last_used_slot

protected static int last_used_slot
Constructor Detail

WaitForCard

public WaitForCard()
Default constructor. Sets a Label for the friendly log-output Since the TestBeans should be beans, please declare only the default constructor.
Method Detail

getNumberOfCards

protected int getNumberOfCards()

getSmartCardArray

public SmartCard[] getSmartCardArray()

getAllSlots

public static Slot[] getAllSlots()

setNumberOfCards

public void setNumberOfCards(int no)

setAllSlotsRequired

public void setAllSlotsRequired()
Set the execution mode.

setAnySlotRequired

public void setAnySlotRequired()

setNextSlotRequired

public void setNextSlotRequired()

setOneSlotRequired

public void setOneSlotRequired(int index)

setOneSlotRequired

public void setOneSlotRequired(Slot slot)

setDefinedSlotsRequired

public void setDefinedSlotsRequired(Slot[] slots)

cardInserted

public void cardInserted(CardTerminalEvent ctEvent)
Gets invoked if a card is inserted.
Specified by:
cardInserted in interface CTListener

cardRemoved

public void cardRemoved(CardTerminalEvent ctEvent)
Gets invoked if a card is removed.
Specified by:
cardRemoved in interface CTListener

execute

public void execute()
             throws TestFailedException
Execute using a previously defined CardTerminal
Throws:
throws - an TestFailedException, if result of this exceution is unexpected or not listed in the result lookup table
Overrides:
execute in class TestBean

toString

public java.lang.String toString()
Overrides:
toString in class TestBean