use of jmri.implementation.AbstractNamedBean in project JMRI by JMRI.
the class AbstractNamedBeanManagerConfigXMLTest method testStoreNullProperty.
public void testStoreNullProperty() {
// Create the manager to test
AbstractNamedBeanManagerConfigXML x = new NamedBeanManagerConfigXMLTest();
// create a NamedBean with two properties to store
NamedBean from = new AbstractNamedBean("sys", "usr") {
@Override
public int getState() {
return 0;
}
@Override
public void setState(int i) {
}
@Override
public String getBeanType() {
return "";
}
};
from.setProperty("foo", null);
from.setProperty("biff", Boolean.valueOf(true));
// create element for properties
Element p = new Element("test");
x.storeProperties(from, p);
// create NamedBean to load
NamedBean to = new AbstractNamedBean("sys", "usr") {
@Override
public int getState() {
return 0;
}
@Override
public void setState(int i) {
}
@Override
public String getBeanType() {
return "";
}
};
x.loadProperties(to, p);
// and test
Assert.assertEquals(null, to.getProperty("foo"));
Assert.assertEquals(Boolean.valueOf(true), to.getProperty("biff"));
}
use of jmri.implementation.AbstractNamedBean in project JMRI by JMRI.
the class AbstractNamedBeanManagerConfigXMLTest method testStoreBean.
public void testStoreBean() {
// Create the manager to test
AbstractNamedBeanManagerConfigXML x = new NamedBeanManagerConfigXMLTest();
// create a NamedBean with two properties to store
NamedBean from = new AbstractNamedBean("sys", "usr") {
@Override
public int getState() {
return 0;
}
@Override
public void setState(int i) {
}
@Override
public String getBeanType() {
return "";
}
};
from.setProperty("foo", "bar");
from.setProperty("biff", Boolean.valueOf(true));
// create element for properties
Element p = new Element("test");
x.storeProperties(from, p);
// create NamedBean to load
NamedBean to = new AbstractNamedBean("sys", "usr") {
@Override
public int getState() {
return 0;
}
@Override
public void setState(int i) {
}
@Override
public String getBeanType() {
return "";
}
};
x.loadProperties(to, p);
// and test
Assert.assertEquals("bar", to.getProperty("foo"));
Assert.assertEquals(Boolean.valueOf(true), to.getProperty("biff"));
}
use of jmri.implementation.AbstractNamedBean in project JMRI by JMRI.
the class AbstractNamedBeanManagerConfigXMLTest method testStoreNoProperties.
public void testStoreNoProperties() {
// Create the manager to test
AbstractNamedBeanManagerConfigXML x = new NamedBeanManagerConfigXMLTest();
// create a NamedBean with two properties to store
NamedBean from = new AbstractNamedBean("sys", "usr") {
@Override
public int getState() {
return 0;
}
@Override
public void setState(int i) {
}
@Override
public String getBeanType() {
return "";
}
};
// create element for properties
Element p = new Element("test");
x.storeProperties(from, p);
// create NamedBean to load
NamedBean to = new AbstractNamedBean("sys", "usr") {
@Override
public int getState() {
return 0;
}
@Override
public void setState(int i) {
}
@Override
public String getBeanType() {
return "";
}
};
x.loadProperties(to, p);
// and test
Assert.assertEquals(null, to.getProperty("foo"));
Assert.assertTrue(to.getPropertyKeys() != null);
Assert.assertEquals(0, to.getPropertyKeys().size());
}
Aggregations