@@ -0,0 +1,3072 @@
+package at.jku.pervasive.ecg;%0A%0Aimport java.util.List;%0A%0Aimport javax.bluetooth.ServiceRecord;%0A%0Aimport junit.framework.TestCase;%0A%0Aimport com.intel.bluetooth.BlueCoveImpl;%0A%0Apublic class ListeningTaskTest extends TestCase %7B%0A%0A  private HeartManSimulator heartManSimulator;%0A  private ServiceRecord serviceRecord;%0A  private Object stackId;%0A%0A  public void testAddListener() throws Exception %7B%0A    ListeningTask listeningTask = new ListeningTask(stackId, serviceRecord);%0A%0A    listeningTask.addListener(new TestHeartManListener());%0A  %7D%0A%0A  public void testAddNullListener() throws Exception %7B%0A    ListeningTask listeningTask = new ListeningTask(stackId, serviceRecord);%0A%0A    try %7B%0A      listeningTask.addListener(null);%0A    %7D catch (Exception e) %7B%0A      fail(%22adding a null listener should not throw an excpetion%22);%0A    %7D%0A  %7D%0A%0A  public void testRemoveListener() throws Exception %7B%0A    ListeningTask listeningTask = new ListeningTask(stackId, serviceRecord);%0A%0A    TestHeartManListener testHeartManListener = new TestHeartManListener();%0A    listeningTask.addListener(testHeartManListener);%0A    try %7B%0A      listeningTask.removeListener(testHeartManListener);%0A    %7D catch (Exception e) %7B%0A      fail(%22removing a listener should not throw an exception%22);%0A    %7D%0A  %7D%0A%0A  public void testRemoveListenerTwice() throws Exception %7B%0A    ListeningTask listeningTask = new ListeningTask(stackId, serviceRecord);%0A%0A    TestHeartManListener testHeartManListener = new TestHeartManListener();%0A    listeningTask.addListener(testHeartManListener);%0A    try %7B%0A      listeningTask.removeListener(testHeartManListener);%0A      listeningTask.removeListener(testHeartManListener);%0A    %7D catch (Exception e) %7B%0A      fail(%22removing a listener twice should not throw an exception%22);%0A    %7D%0A  %7D%0A%0A  public void testRemoveListenerWhichHasNotBeenAdded() throws Exception %7B%0A    ListeningTask listeningTask = new ListeningTask(stackId, serviceRecord);%0A%0A    TestHeartManListener testHeartManListener = new TestHeartManListener();%0A    try %7B%0A      listeningTask.removeListener(testHeartManListener);%0A    %7D catch (Exception e) %7B%0A      fail(%22removing a listener which has not been added should not throw an exception%22);%0A    %7D%0A  %7D%0A%0A  public void testRemoveNullListener() throws Exception %7B%0A    ListeningTask listeningTask = new ListeningTask(stackId, serviceRecord);%0A%0A    try %7B%0A      listeningTask.removeListener(null);%0A    %7D catch (Exception e) %7B%0A      fail(%22removing a null listener should not throw an exception%22);%0A    %7D%0A  %7D%0A%0A  @Override%0A  protected void setUp() throws Exception %7B%0A    super.setUp();%0A%0A    heartManSimulator = new HeartManSimulator();%0A    HeartManDiscovery heartManDiscovery = new HeartManDiscovery();%0A%0A    String address = heartManSimulator.createDevice();%0A    heartManDiscovery.discoverHeartManDevices();%0A    List%3CServiceRecord%3E services = heartManDiscovery.searchServices(address);%0A    serviceRecord = services.get(0);%0A%0A    stackId = BlueCoveImpl.getThreadBluetoothStackID();%0A  %7D%0A%0A  @Override%0A  protected void tearDown() throws Exception %7B%0A    super.tearDown();%0A%0A    heartManSimulator.stopServer();%0A  %7D%0A%0A%7D%0A

add tests for ListeningTask