use of java.beans.PropertyChangeEvent in project JMRI by JMRI.
the class IntTriggerTest method testPropertyChange.
@Test
public void testPropertyChange() {
IntTrigger uut = new IntTrigger("unitUnderTest", 4, Trigger.CompareType.EQ);
uut.setEventName("test event");
uut.setMatchValue(2);
uut.setCallback(new TriggerListener() {
@Override
public void takeAction() {
Assert.assertTrue("callback called", true);
}
@Override
public void takeAction(int i) {
Assert.fail("wrong callback called");
}
@Override
public void takeAction(float f) {
Assert.fail("wrong callback called");
}
});
uut.setCompareType(Trigger.CompareType.GT);
PropertyChangeEvent e = new PropertyChangeEvent(this, "test event", Integer.valueOf(1), Integer.valueOf(3));
uut.propertyChange(e);
uut.setCompareType(Trigger.CompareType.LT);
e = new PropertyChangeEvent(this, "test event", 3, 1);
//new Integer(3),
//new Integer(1));
uut.propertyChange(e);
uut.setCompareType(Trigger.CompareType.GTE);
e = new PropertyChangeEvent(this, "test event", Integer.valueOf(1), Integer.valueOf(2));
uut.propertyChange(e);
uut.setCompareType(Trigger.CompareType.LTE);
e = new PropertyChangeEvent(this, "test event", Integer.valueOf(3), Integer.valueOf(2));
uut.propertyChange(e);
uut.setCompareType(Trigger.CompareType.EQ);
e = new PropertyChangeEvent(this, "test event", Integer.valueOf(3), Integer.valueOf(2));
uut.propertyChange(e);
}
use of java.beans.PropertyChangeEvent in project JMRI by JMRI.
the class NotchTriggerTest method testPropertyChange.
@Test
public void testPropertyChange() {
NotchTrigger uut = new NotchTrigger("unitUnderTest", 4, 5);
uut.setEventName("test event");
uut.setCallback(new TriggerListener() {
@Override
public void takeAction() {
Assert.fail("wrong callback called");
}
@Override
public void takeAction(int i) {
Assert.assertTrue("callback called", true);
}
@Override
public void takeAction(float f) {
Assert.fail("wrong callback called");
}
});
// 2/8 = 0.25
uut.setNotch(2);
PropertyChangeEvent e = new PropertyChangeEvent(this, "test event", 0.2f, 0.3f);
uut.propertyChange(e);
e = new PropertyChangeEvent(this, "test event", 0.3, 0.2);
uut.propertyChange(e);
}
use of java.beans.PropertyChangeEvent in project JMRI by JMRI.
the class BoolTriggerTest method testPropertyChange.
@Test
public void testPropertyChange() {
BoolTrigger uut = new BoolTrigger("unitUnderTest", false);
uut.setEventName("test event");
uut.setMatchValue(true);
uut.setCallback(new TriggerListener() {
@Override
public void takeAction() {
Assert.assertTrue("callback called", true);
}
@Override
public void takeAction(int i) {
Assert.fail("wrong callback called");
}
@Override
public void takeAction(float f) {
Assert.fail("wrong callback called");
}
});
PropertyChangeEvent e = new PropertyChangeEvent(this, "test event", Boolean.valueOf(false), Boolean.valueOf(true));
uut.propertyChange(e);
}
use of java.beans.PropertyChangeEvent in project JMRI by JMRI.
the class FloatTriggerTest method testPropertyChange.
@Test
public void testPropertyChange() {
FloatTrigger uut = new FloatTrigger("unitUnderTest", 1.5f, Trigger.CompareType.EQ);
uut.setEventName("test event");
uut.setMatchValue(0.5f);
uut.setCompareType(Trigger.CompareType.GT);
uut.setCallback(new TriggerListener() {
@Override
public void takeAction() {
Assert.assertTrue("callback called", true);
}
@Override
public void takeAction(int i) {
Assert.fail("wrong callback called");
}
@Override
public void takeAction(float f) {
Assert.fail("wrong callback called");
}
});
PropertyChangeEvent e = new PropertyChangeEvent(this, "test event", new Float(1.0f), new Float(2.0f));
uut.propertyChange(e);
uut.setCompareType(Trigger.CompareType.LT);
e = new PropertyChangeEvent(this, "test event", new Float(2.0f), new Float(1.0f));
uut.propertyChange(e);
uut.setCompareType(Trigger.CompareType.GTE);
e = new PropertyChangeEvent(this, "test event", new Float(2.0f), new Float(0.5f));
uut.propertyChange(e);
uut.setCompareType(Trigger.CompareType.LTE);
e = new PropertyChangeEvent(this, "test event", new Float(2.0f), new Float(0.5f));
uut.propertyChange(e);
uut.setCompareType(Trigger.CompareType.EQ);
e = new PropertyChangeEvent(this, "test event", new Float(2.0f), new Float(0.5f));
uut.propertyChange(e);
}
use of java.beans.PropertyChangeEvent in project JMRI by JMRI.
the class AbstractThrottleTest method testRemovePropertyChangeListener.
/**
* Test of removePropertyChangeListener method, of class AbstractThrottle.
*/
public void testRemovePropertyChangeListener() {
PropertyChangeListener l = (PropertyChangeEvent evt) -> {
};
AbstractThrottle instance = new AbstractThrottleImpl();
instance.removePropertyChangeListener(l);
}
Aggregations