/** Test method for {@link KNXNetworkMonitorFT12#getName()}. */
 @Test
 public final void testGetName() {
   String n = mon.getName();
   final String port = Util.getSerialPortID();
   assertTrue(n.indexOf(port) > -1, port);
   assertTrue(n.indexOf("monitor") > -1);
   mon.close();
   n = mon.getName();
   assertNotNull(n);
   assertTrue(n.indexOf("monitor") > -1);
 }
 /**
  * Test method for {@link KNXNetworkMonitorFT12#setDecodeRawFrames(boolean)}.
  *
  * @throws InterruptedException on interrupted thread
  */
 @Test
 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 KNXNetworkMonitorFT12#KNXNetworkMonitorFT12(int,
  * medium.KNXMediumSettings)}.
  */
 @Test
 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 KNXNetworkMonitorFT12#setKNXMedium(medium.KNXMediumSettings)}. */
  @Test
  public final void testSetKNXMedium() {
    try {
      mon.setKNXMedium(new PLSettings());
      fail("different medium");
    } catch (final KNXIllegalArgumentException e) {
    }
    final class TPSettingsSubClass extends TPSettings {
      TPSettingsSubClass() {
        super();
      }
    }
    // replace basetype with subtype
    mon.setKNXMedium(new TPSettingsSubClass());
    // replace subtype with its supertype
    mon.setKNXMedium(new TPSettings());

    mon.setKNXMedium(new TPSettings(new IndividualAddress(200)));
    assertEquals(200, mon.getKNXMedium().getDeviceAddress().getRawAddress());
  }
 @BeforeEach
 void setUp() throws Exception {
   try {
     // prevents access problems with a just previously closed port
     Thread.sleep(50);
     mon = new KNXNetworkMonitorFT12(Util.getSerialPort(), TPSettings.TP1);
   } catch (final Exception e) {
     Util.tearDownLogging();
     throw e;
   }
   lmon = new MonListener();
   mon.addMonitorListener(lmon);
 }
 /**
  * Test method for {@link KNXNetworkMonitorFT12#close()}.
  *
  * @throws InterruptedException on interrupted thread
  */
 @Test
 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 KNXNetworkMonitorFT12#KNXNetworkMonitorFT12(java.lang.String,
  * medium.KNXMediumSettings)}.
  *
  * @throws KNXException
  */
 @Test
 public final void testKNXNetworkMonitorFT12StringKNXMediumSettings() throws KNXException {
   mon.close();
   mon = new KNXNetworkMonitorFT12(Util.getSerialPortID(), TPSettings.TP1);
 }
 @AfterEach
 void tearDown() throws Exception {
   if (mon != null) mon.close();
 }