i'm very sorry that this one slipped through my net for so long. your patch was very good, i just missed your mail.
i've now applied your patch. many thanks.
- robert
On 17 Mar 2004, at 22:40, b p wrote:
Hi Robert,
I've gotten back to working with betwixt and I am still working off your refactoring branch. I've found a problem in reading Maps because the "adder" is not getting called correctly in MapEntryAdder (seems to be confusing the types of the key and value). I've included a patch that has a test case as well a fix to MapEntryAdder. Could you take a look and if this looks like a valid problem and fix commit the patch?
Thanks, Brian
? betwixt-refactor-branch-orig/src/test/org/apache/commons/betwixt/ IdMap.java
Index: betwixt-refactor-branch-orig/src/java/org/apache/commons/betwixt/ expression/MapEntryAdder.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/betwixt/src/java/org/apache/commons/ betwixt/expression/MapEntryAdder.java,v
retrieving revision 1.4
diff -u -r1.4 MapEntryAdder.java
--- betwixt-refactor-branch-orig/src/java/org/apache/commons/betwixt/ expression/MapEntryAdder.java 9 Oct 2003 20:52:04 -0000 1.4
+++ betwixt-refactor-branch-orig/src/java/org/apache/commons/betwixt/ expression/MapEntryAdder.java 17 Mar 2004 22:27:37 -0000
@@ -235,13 +235,13 @@
if ( key instanceof String ) {
// try to convert into primitive types
key = context.getObjectStringConverter()
- .stringToObject( (String) key, valueType, null, context );
+ .stringToObject( (String) key, keyType, null, context );
}
if ( value instanceof String ) {
// try to convert into primitive types
value = context.getObjectStringConverter()
- .stringToObject( (String) value, keyType, null, context );
+ .stringToObject( (String) value, valueType, null, context );
}
Object[] arguments = { key, value };
Index: betwixt-refactor-branch-orig/src/test/org/apache/commons/betwixt/ TestBeanReader.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons/betwixt/src/test/org/apache/commons/ betwixt/TestBeanReader.java,v
retrieving revision 1.21.2.3
diff -u -r1.21.2.3 TestBeanReader.java
--- betwixt-refactor-branch-orig/src/test/org/apache/commons/betwixt/ TestBeanReader.java 18 Jan 2004 22:25:23 -0000 1.21.2.3
+++ betwixt-refactor-branch-orig/src/test/org/apache/commons/betwixt/ TestBeanReader.java 17 Mar 2004 22:27:37 -0000
@@ -686,7 +686,27 @@
assertEquals("Bad address (11)", "United Kingdom", address.getCountry());
assertEquals("Bad address (12)", "BD18 2BJ", address.getCode());
}
-
+
+ public void testReadMap2() throws Exception{
+ IdMap idMap = new IdMap();
+ String id ="3920";
+ idMap.addId(id, new Integer(1));
+ StringWriter outputWriter = new StringWriter();
+ outputWriter.write("<?xml version='1.0' ?>\n");
+ BeanWriter beanWriter = new BeanWriter(outputWriter);
+ beanWriter.write(idMap);
+ String xml = outputWriter.toString();
+ System.out.println("Map test: " + xml);
+
+ BeanReader beanReader = new BeanReader();
+ beanReader.registerBeanClass(IdMap.class);
+ IdMap result = (IdMap)beanReader.parse(new StringReader(xml));
+ assertNotNull("didn't get an object back!", result);
+ assertNotNull("didn't get a Map out of the IdMap!", result.getIds());
+ assertEquals("Got the Map, but doesn't have an entry!", 1, result.getIds().size());
+ assertNotNull("Got the Map, but doesn't have correct values!", result.getIds().get(id));
+ }
+
public void testIndirectReference() throws Exception
{
Tweedledum dum = new Tweedledum();
-----------------------------------------------------------
package org.apache.commons.betwixt; import java.util.HashMap; import java.util.Map; /** * @author Brian Pugh */ public class IdMap { private Map ids = new HashMap(); public Map getIds() { return ids; } public void addId(String key, Integer value) { this.ids.put(key, value); } }
Do you Yahoo!? Yahoo! Mail - More reliable, more storage, less spam
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
