示例#1
0
  /**
   * Test method for {@link at.ac.tuwien.auto.calimero.datapoint.StateDP#StateDP(
   * at.ac.tuwien.auto.calimero.GroupAddress, java.lang.String, java.util.Collection,
   * java.util.Collection)}.
   */
  public final void testStateDPGroupAddressStringCollectionCollection() {
    final StateDP dp = new StateDP(ga, "test", inv, upd);
    assertEquals(ga, dp.getMainAddress());
    assertEquals("test", dp.getName());
    assertTrue(dp.isStateBased());

    Collection c = dp.getAddresses(false);
    assertEquals(3, c.size());
    assertTrue(c.contains(new GroupAddress(1, 1, 1)));
    assertTrue(c.contains(new GroupAddress(2, 2, 2)));
    assertTrue(c.contains(new GroupAddress(3, 3, 3)));
    try {
      c.add(new Object());
      fail("collection should be unmodifiable");
    } catch (final UnsupportedOperationException e) {
    }

    c = dp.getAddresses(true);
    assertEquals(2, c.size());
    assertTrue(c.contains(new GroupAddress(4, 4, 4)));
    assertTrue(c.contains(new GroupAddress(5, 5, 5)));
    try {
      c.add(new Object());
      fail("collection should be unmodifiable");
    } catch (final UnsupportedOperationException e) {
    }
  }
示例#2
0
 /**
  * Test method for {@link at.ac.tuwien.auto.calimero.datapoint.StateDP#StateDP(
  * at.ac.tuwien.auto.calimero.xml.XMLReader)}.
  *
  * @throws KNXMLException
  */
 public final void testStateDPXMLReader() throws KNXMLException {
   final XMLWriter w = XMLFactory.getInstance().createXMLWriter(dpFile);
   StateDP dp = new StateDP(ga, "testSave2", inv, upd);
   dp.setExpirationTimeout(15);
   dp.save(w);
   w.close();
   final XMLReader r = XMLFactory.getInstance().createXMLReader(dpFile);
   dp = new StateDP(r);
   r.close();
   assertEquals(ga, dp.getMainAddress());
   assertEquals("testSave2", dp.getName());
   assertTrue(dp.isStateBased());
   assertEquals(0, dp.getMainNumber());
   assertNull(dp.getDPT());
   assertEquals(15, dp.getExpirationTimeout());
   assertEquals(upd, new ArrayList(dp.getAddresses(true)));
   assertEquals(inv, new ArrayList(dp.getAddresses(false)));
 }