uk.co.keang.callerid.driver
Class CallSimulator

java.lang.Object
  extended by uk.co.keang.callerid.driver.CallSimulator

public class CallSimulator
extends java.lang.Object

Simulates incoming phone calls.

This will always wait at least 200 mSec between sending a series of call data streams.

The simulator is used in system testing and does not require the hardware to be attached. You can create a simulator with a random set of phone numbers or you can give it a list of phone numbers to simulate calls from. ie

 
    // create an array of phone numbers to call where 'null' is number withheld
    String[] nums = new String[] {null, "01482571234", "01482576666", "01482571111", "01482570000", "01482575555", "01482578888"};
    CallSimulator sim = new CallSimulator(nums);

    callerID = new CTICallerID(sim);
    callerID.addCallerIDListener(new ICallerIDListener()
              {
              public void incomingCall(CallerIDEvent event)
                  {
                  // Handle incoming calls
                  }

              public void callerIDException(Exception e)
                  {
                  // Handle any exceptions caught by the driver
                  }
              });

    // call a random number from the supplied list
    sim.callRandomNumber();
 
 

Version:
1.0 - 23 Jan 2014
Author:
Keang

Constructor Summary
CallSimulator()
          A simulator with 10 random phone numbers
CallSimulator(int n)
          A simulator with the given number of random phone numbers
CallSimulator(java.lang.String[] nums)
          A simulator with the given list of phone numbers
CallSimulator(java.lang.String[] nums, long initialDelay, long repeatDelay)
          A simulator with the given list of phone numbers that automatically calls them in order
CallSimulator(java.lang.String[] nums, long initialDelay, long repeatDelay, java.util.TimerTask task)
          A simulator with the given list of phone numbers that automatically runs the task at the specified frequency
 
Method Summary
 void callNextNumber()
          Simulates a call from the next number in the list
 void callNumber(java.lang.String num)
          Simulates a call from the given number
 void callNumberWithHeld()
          Simulates a call from a number withheld
 void callRandomNumber()
          Simulates a call from a random number from the list
 void close()
          Closes the streams
(package private)  java.io.PipedInputStream getInputStream()
          Gets the input stream that will contain the caller ID data
 void sendBadChecksum()
          Sends a corrupted data stream, ie one with a bad checksum
 void sendTruncated()
          Sends a short data stream, ie one which is missing part of the data
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CallSimulator

public CallSimulator()
A simulator with 10 random phone numbers


CallSimulator

public CallSimulator(int n)
A simulator with the given number of random phone numbers


CallSimulator

public CallSimulator(java.lang.String[] nums)
A simulator with the given list of phone numbers

Parameters:
nums - the telephone numbers

CallSimulator

public CallSimulator(java.lang.String[] nums,
                     long initialDelay,
                     long repeatDelay)
A simulator with the given list of phone numbers that automatically calls them in order

Parameters:
nums - the telephone numbers
initialDelay - the time to wait before firing any events
repeatDelay - the time to wait between events

CallSimulator

public CallSimulator(java.lang.String[] nums,
                     long initialDelay,
                     long repeatDelay,
                     java.util.TimerTask task)
A simulator with the given list of phone numbers that automatically runs the task at the specified frequency

Parameters:
nums - the telephone numbers
initialDelay - the time to wait before firing any events
repeatDelay - the time to wait between events
task - the task to run
Method Detail

getInputStream

java.io.PipedInputStream getInputStream()
Gets the input stream that will contain the caller ID data

Returns:
the input stream

callNextNumber

public void callNextNumber()
Simulates a call from the next number in the list


callRandomNumber

public void callRandomNumber()
Simulates a call from a random number from the list


callNumber

public void callNumber(java.lang.String num)
Simulates a call from the given number

Parameters:
num - the number to call

callNumberWithHeld

public void callNumberWithHeld()
Simulates a call from a number withheld


sendBadChecksum

public void sendBadChecksum()
Sends a corrupted data stream, ie one with a bad checksum


sendTruncated

public void sendTruncated()
Sends a short data stream, ie one which is missing part of the data


close

public void close()
Closes the streams