commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kristian Mandrup" <krist...@mandrup.dk>
Subject [beanutils] [betwixt] - disappearing Map entries! Map collection still broken??? update unit tests for Maps?
Date Sat, 27 Nov 2004 15:44:21 GMT
Did a CVS update, no changes received, used the latest Betwixt 0.6.1-dev

 

For some VERY STRANGE REASON, some of the map entries disappear when
reading. 

Looks to me like the Map collection integration is still broken!!! 

 

Only seems to work for map values that are set in constructor, not for
values set after object has been constructed!!!! VERY STRANGE!!!

 

 

Using Betwixt to write a DynaBean and read it back again (see previous
posts):

 

Entries 6,7 and 9 disappear!!!

 

Setting “from the outside”

DynaBeanAdapter dynaBean = new DynaBeanAdapter(dynaClass);

        dynaBean.set("name", "Kristian Mandrup");

        dynaBean.set("age", new Integer(30));

        dynaBean.set("married", new Boolean(false));

 

Gives the following result with disapperaring entries marked in red!

 

 

<?xml version='1.0' ?>  <dynabean class="betwixt.DynaBeanAdapter"
className="betwixt.DynaBeanAdapter" id="1">

    <dynaClass class="betwixt.DynaClassAdapter"
className="betwixt.DynaClassAdapter"
dynaBeanClass="org.apache.commons.beanutils.BasicDynaBean" name="Person"
id="2">

      <dynaProperties>

        <DynaPropertyAdapter class="betwixt.DynaPropertyAdapter"
className="betwixt.DynaPropertyAdapter" name="name" type="java.lang.String"
id="3"/>

        <DynaPropertyAdapter class="betwixt.DynaPropertyAdapter"
className="betwixt.DynaPropertyAdapter" name="age" type="java.lang.Integer"
id="4"/>

        <DynaPropertyAdapter class="betwixt.DynaPropertyAdapter"
className="betwixt.DynaPropertyAdapter" name="married"
type="java.lang.Boolean" id="5"/>

      </dynaProperties>

    </dynaClass>

    <dynaClassRef idref="2"/>

    <mapValues>

      <entry class="java.util.HashMap$Entry" id="6">

        <key>married</key>

        <value>false</value>

      </entry>

      <entry class="java.util.HashMap$Entry" id="7">

        <key>age</key>

        <value>30</value>

      </entry>

      <entry class="java.util.HashMap$Entry" id="8">

        <key>bold</key>

        <value>Ole</value>

      </entry>

      <entry class="java.util.HashMap$Entry" id="9">

        <key>name</key>

        <value>Kristian Mandrup</value>

      </entry>

      <entry class="java.util.HashMap$Entry" id="10">

        <key>abe</key>

        <value>Peter</value>

      </entry>

    </mapValues>

    <names>

      <String>hello</String>

      <String>mister</String>

    </names>

    <numbers>

      <entry class="java.util.HashMap$Entry" id="11">

        <key>a</key>

        <value>10</value>

      </entry>

      <entry class="java.util.HashMap$Entry" id="12">

        <key>b</key>

        <value>14</value>

      </entry>

    </numbers>

    <values>

      <entry idref="6"/>

      <entry idref="7"/>

      <entry idref="8"/>

      <entry idref="9"/>

      <entry idref="10"/>

    </values>

  </dynabean>

 

Then reading the DynaBean back again, where did the entries go???

 

betwixt.DynaBeanAdapter@13bd574

DynaBean:betwixt.DynaBeanAdapter@13bd574

<?xml version='1.0' ?>  <dynabean class="betwixt.DynaBeanAdapter"
className="betwixt.DynaBeanAdapter" id="1">

    <mapValues>

      <entry class="java.util.HashMap$Entry" id="2">

        <key>bold</key>

        <value>Ole</value>

      </entry>

      <entry class="java.util.HashMap$Entry" id="3">

        <key>abe</key>

        <value>Peter</value>

      </entry>

    </mapValues>

    <names>

      <String>hello</String>

      <String>mister</String>

    </names>

    <numbers>

      <entry class="java.util.HashMap$Entry" id="4">

        <key>a</key>

        <value>10</value>

      </entry>

      <entry class="java.util.HashMap$Entry" id="5">

        <key>b</key>

        <value>14</value>

      </entry>

    </numbers>

    <values>

      <entry idref="2"/>

      <entry idref="3"/>

    </values>

  </dynabean>

 

Setting the values ”on the inside” in the constructor

 

    public DynaBeanAdapter(DynaClass dynaClass) {

        super(dynaClass);

        setDynaClassRef(dynaClass);

        names.add("hello");

        names.add("mister");

        numbers.put("a", new Integer(10));

        numbers.put("b", new Integer(14));

        addMapValue("abe", "Peter");

        addMapValue("bold", "Ole"); 

        addValue("name", "Kristian Mandrup");

        addValue("age", new Integer(30));

        addValue("married", new Boolean(false));        

    }  

 

Gives the right result!!!

 

Update the unit tests to check for this problem

 

betwixt.DynaBeanAdapter@13bd574

DynaBean:betwixt.DynaBeanAdapter@13bd574

<?xml version='1.0' ?>  <dynabean class="betwixt.DynaBeanAdapter"
className="betwixt.DynaBeanAdapter" id="1">

    <mapValues>

      <entry class="java.util.HashMap$Entry" id="2">

        <key>bold</key>

        <value>Ole</value>

      </entry>

      <entry class="java.util.HashMap$Entry" id="3">

        <key>abe</key>

        <value>Peter</value>

      </entry>

    </mapValues>

    <names>

      <String>hello</String>

      <String>mister</String>

    </names>

    <numbers>

      <entry class="java.util.HashMap$Entry" id="4">

        <key>a</key>

        <value>10</value>

      </entry>

      <entry class="java.util.HashMap$Entry" id="5">

        <key>b</key>

        <value>14</value>

      </entry>

    </numbers>

    <values>

      <entry class="java.util.HashMap$Entry" id="6">

        <key>married</key>

        <value>false</value>

      </entry>

      <entry class="java.util.HashMap$Entry" id="7">

        <key>age</key>

        <value>30</value>

      </entry>

      <entry class="java.util.HashMap$Entry" id="8">

        <key>name</key>

        <value>Kristian Mandrup</value>

      </entry>

    </values>

  </dynabean>

 


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.779 / Virus Database: 526 - Release Date: 19-10-2004
 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message