/** 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()); }
/** * 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) { } }
/** * 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))); }
/** * 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))); }