commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "marc & lan" <marc...@free.fr>
Subject Re: [betwixt] Collection and elements
Date Sun, 06 Mar 2005 17:35:22 GMT
Is it a silly question ?

> Hi guys.
> I belevied I was mastering betwixt : I was wrong.
> Look at this :
> I get a class NameBunch :
> - - - - - - - - - - - - - - - -
> public class NameBunch  {
> 
>    private String name;
>    private ArrayList sqlNames;
> 
>    public NameBunch(){
>        sqlNames = new ArrayList();
>    }
>    public String getName() {
>        return name;
>    }
>    public void setName(String name) {
>        this.name = name;
>    }
>    public ArrayList getSqlNames() {
>        return sqlNames;
>    }
> 
>    public void addSqlName(String sqlName) {
>        getSqlNames().add(sqlName);
>    }
> }
> - - - - - - - - - - - - - - - -
> An input file like this :
> 
> <?xml version="1.0" encoding="UTF-8" ?>
>  <bunch name="bunch_name">
>    <sql>sql_name0</sql>
>    <sql>sql_name1</sql>
>    <sql>sql_name2</sql>
>  </bunch>
> 
> I have tried many betwixt file, but I can't make betwixt add sql
> content. What do you think it' wrong with
> 
> <?xml version="1.0" encoding="UTF-8" ?>
> <info primitiveTypes="element">
>    <element name="bunch">
>        <attribute name="name" property="name"/>
>        <element name="sql" property="sqlNames" updater="addSqlName"/>
>    </element>
> </info>
> 
> --
> UnitTest method :
> 
> 
>    public void testReadBetwixt() throws IntrospectionException,
> IOException, SAXException {
>        String xml =
>            "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"+
>            "<bunch name=\"bunch_name\">"+
>            "<sql>sql_name0</sql>"+
>            "<sql>sql_name1</sql>"+
>            "<sql>sql_name2</sql>"+
>            "</bunch>";
> 
>        BeanReader reader = new BeanReader();
>        reader.registerBeanClass(NameBunch.class);
>        Object obj = reader.parse( new StringReader(xml) );
>        assertTrue( obj instanceof NameBunch );
>        NameBunch nb = (NameBunch) obj;
>        assertEquals("bunch_name",nb.getName());
>        assertFalse("is empty",nb.getSqlNames().isEmpty());
>        assertTrue("sql_name0",nb.getSqlNames().contains("sql_name0"));
>        assertTrue(nb.getSqlNames().contains("sql_name1"));
>        assertTrue(nb.getSqlNames().contains("sql_name2"));

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message