Beispiel #1
0
 /** Test method for {@link at.ac.tuwien.auto.calimero.datapoint.StateDP#getAddresses(boolean)}. */
 public final void testGetAddresses() {
   final StateDP dp = new StateDP(ga, "test", inv, upd);
   assertNotNull(dp.getAddresses(true));
   assertNotNull(dp.getAddresses(false));
   assertEquals(2, dp.getAddresses(true).size());
   assertEquals(3, dp.getAddresses(false).size());
 }
Beispiel #2
0
 /**
  * Test method for {@link at.ac.tuwien.auto.calimero.datapoint.StateDP#isUpdating(
  * at.ac.tuwien.auto.calimero.GroupAddress)}.
  */
 public final void testIsUpdating() {
   final StateDP dp = new StateDP(ga, "test");
   dp.add(new GroupAddress(2, 2, 2), true);
   assertTrue(dp.isUpdating(new GroupAddress(2, 2, 2)));
   dp.add(new GroupAddress(1, 1, 1), false);
   assertFalse(dp.isUpdating(new GroupAddress(1, 1, 1)));
 }
Beispiel #3
0
 /**
  * Test method for {@link at.ac.tuwien.auto.calimero.datapoint.StateDP#remove(
  * at.ac.tuwien.auto.calimero.GroupAddress, boolean)}.
  */
 public final void testRemove() {
   final StateDP dp = new StateDP(ga, "name1", inv, upd);
   assertTrue(dp.isInvalidating(new GroupAddress(1, 1, 1)));
   dp.remove(new GroupAddress(1, 1, 1), false);
   assertFalse(dp.isInvalidating(new GroupAddress(1, 1, 1)));
   assertTrue(dp.isUpdating(new GroupAddress(4, 4, 4)));
   dp.remove(new GroupAddress(4, 4, 4), true);
   assertFalse(dp.isUpdating(new GroupAddress(4, 4, 4)));
 }
Beispiel #4
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) {
    }
  }
Beispiel #5
0
 /**
  * Test method for {@link at.ac.tuwien.auto.calimero.datapoint.StateDP#add(
  * at.ac.tuwien.auto.calimero.GroupAddress, boolean)}.
  */
 public final void testAdd() {
   final StateDP dp = new StateDP(ga, "name1", inv, upd);
   for (final Iterator i = upd.iterator(); i.hasNext(); ) {
     final GroupAddress a = (GroupAddress) i.next();
     dp.add(a, true);
   }
   assertEquals(upd.size(), dp.getAddresses(true).size());
   for (final Iterator i = inv.iterator(); i.hasNext(); ) {
     final GroupAddress a = (GroupAddress) i.next();
     dp.add(a, false);
   }
   assertEquals(inv.size(), dp.getAddresses(false).size());
   dp.add(new GroupAddress(5, 5, 5), false);
   assertEquals(inv.size() + 1, dp.getAddresses(false).size());
   assertTrue(dp.isInvalidating(new GroupAddress(5, 5, 5)));
 }
Beispiel #6
0
 /**
  * Test method for {@link at.ac.tuwien.auto.calimero.datapoint.StateDP#setExpirationTimeout(int)}.
  */
 public final void testSetExpirationTimeout() {
   final StateDP dp = new StateDP(ga, "test");
   assertEquals(0, dp.getExpirationTimeout());
   dp.setExpirationTimeout(1000);
   assertEquals(1000, dp.getExpirationTimeout());
 }
Beispiel #7
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)));
 }