Search in sources :

Example 1 with AbstractNamedBean

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"));
}
Also used : AbstractNamedBean(jmri.implementation.AbstractNamedBean) AbstractNamedBean(jmri.implementation.AbstractNamedBean) NamedBean(jmri.NamedBean) Element(org.jdom2.Element)

Example 2 with AbstractNamedBean

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"));
}
Also used : AbstractNamedBean(jmri.implementation.AbstractNamedBean) AbstractNamedBean(jmri.implementation.AbstractNamedBean) NamedBean(jmri.NamedBean) Element(org.jdom2.Element)

Example 3 with AbstractNamedBean

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());
}
Also used : AbstractNamedBean(jmri.implementation.AbstractNamedBean) AbstractNamedBean(jmri.implementation.AbstractNamedBean) NamedBean(jmri.NamedBean) Element(org.jdom2.Element)

Aggregations

NamedBean (jmri.NamedBean)3 AbstractNamedBean (jmri.implementation.AbstractNamedBean)3 Element (org.jdom2.Element)3