/** Test method for {@link at.ac.tuwien.auto.calimero.link.KNXNetworkMonitorFT12#getName()}. */
 public final void testGetName() {
   String n = mon.getName();
   final String port = Util.getSerialPortID();
   assertTrue(port, n.indexOf(port) > -1);
   assertTrue(n.indexOf("monitor") > -1);
   mon.close();
   n = mon.getName();
   assertNotNull(n);
   assertTrue(n.indexOf("monitor") > -1);
 }
 /**
  * Test method for {@link
  * at.ac.tuwien.auto.calimero.link.KNXNetworkMonitorFT12#setDecodeRawFrames(boolean)}.
  *
  * @throws InterruptedException
  */
 public final void testSetDecodeRawFrames() throws InterruptedException {
   mon.setDecodeRawFrames(true);
   lmon.raw = null;
   System.out.println("monitor: waiting for incoming frames..");
   Thread.sleep(10 * 1000);
   assertNotNull(lmon.raw);
   mon.setDecodeRawFrames(false);
   lmon.raw = null;
   Thread.sleep(10 * 1000);
   assertNull(lmon.raw);
 }
 /**
  * Test method for {@link
  * at.ac.tuwien.auto.calimero.link.KNXNetworkMonitorFT12#KNXNetworkMonitorFT12(int,
  * at.ac.tuwien.auto.calimero.link.medium.KNXMediumSettings)}.
  */
 public final void testKNXNetworkMonitorFT12IntKNXMediumSettings() {
   mon.close();
   try {
     mon = new KNXNetworkMonitorFT12(1055, TPSettings.TP1);
     fail("should fail");
   } catch (final KNXException e) {
     System.out.println(e.getMessage());
   }
 }
  /**
   * Test method for {@link at.ac.tuwien.auto.calimero.link.KNXNetworkMonitorFT12#setKNXMedium
   * (at.ac.tuwien.auto.calimero.link.medium.KNXMediumSettings)}.
   */
  public final void testSetKNXMedium() {
    try {
      mon.setKNXMedium(new PLSettings(true));
      fail("different medium");
    } catch (final KNXIllegalArgumentException e) {
    }
    final class TPSettingsSubClass extends TPSettings {
      TPSettingsSubClass() {
        super(false);
      }
    }
    // replace basetype with subtype
    mon.setKNXMedium(new TPSettingsSubClass());
    // replace subtype with its supertype
    mon.setKNXMedium(new TPSettings(true));

    mon.setKNXMedium(new TPSettings(new IndividualAddress(200), true));
    assertEquals(200, mon.getKNXMedium().getDeviceAddress().getRawAddress());
  }
 /* (non-Javadoc)
  * @see junit.framework.TestCase#setUp()
  */
 protected void setUp() throws Exception {
   super.setUp();
   LogManager.getManager().addWriter(null, Util.getLogWriter());
   try {
     // prevents access problems with a just previously closed port
     Thread.sleep(50);
     mon = new KNXNetworkMonitorFT12(Util.getSerialPort(), TPSettings.TP1);
   } catch (final Exception e) {
     LogManager.getManager().removeWriter(null, Util.getLogWriter());
     throw e;
   }
   lmon = new MonListener();
   mon.addMonitorListener(lmon);
 }
 /**
  * Test method for {@link at.ac.tuwien.auto.calimero.link.KNXNetworkMonitorFT12#close()}.
  *
  * @throws InterruptedException
  */
 public final void testClose() throws InterruptedException {
   System.out.println(mon.toString());
   assertTrue(mon.isOpen());
   mon.close();
   // time for link event notifier
   Thread.sleep(50);
   assertTrue(lmon.closed);
   assertFalse(mon.isOpen());
   mon.close();
   System.out.println(mon.toString());
 }
 /**
  * Test method for {@link
  * at.ac.tuwien.auto.calimero.link.KNXNetworkMonitorFT12#KNXNetworkMonitorFT12 (java.lang.String,
  * at.ac.tuwien.auto.calimero.link.medium.KNXMediumSettings)}.
  *
  * @throws KNXException
  */
 public final void testKNXNetworkMonitorFT12StringKNXMediumSettings() throws KNXException {
   mon.close();
   mon = new KNXNetworkMonitorFT12(Util.getSerialPortID(), TPSettings.TP1);
 }
 /* (non-Javadoc)
  * @see junit.framework.TestCase#tearDown()
  */
 protected void tearDown() throws Exception {
   if (mon != null) mon.close();
   LogManager.getManager().removeWriter(null, Util.getLogWriter());
   super.tearDown();
 }