Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: Upcoming
-
Fix Version/s: 1.3
-
Component/s: Annotations, Converters
-
Labels:None
-
JDK version and platform:Ubuntu Linux 7.10, Java version 1.6.0_03
Description
I get an InitilizationException when i try to process an annotation for a MapConverter subclass. Below is output of my testcast.
com.thoughtworks.xstream.InitializationException: Cannot instantiate converter com.thoughtworks.acceptance.annotations.MapConverterTest$MyMapConverter : Cannot construct com.thoughtworks.acceptance.annotations.MapConverterTest$MyMapConverter, none of the dependencies match any constructor's parameters
at com.thoughtworks.xstream.mapper.AnnotationMapper.cacheConverter(AnnotationMapper.java:431)
at com.thoughtworks.xstream.mapper.AnnotationMapper.processConverterAnnotations(AnnotationMapper.java:264)
at com.thoughtworks.xstream.mapper.AnnotationMapper.processTypes(AnnotationMapper.java:162)
at com.thoughtworks.xstream.mapper.AnnotationMapper.processAnnotations(AnnotationMapper.java:134)
at com.thoughtworks.xstream.XStream.processAnnotations(XStream.java:1440)
at com.thoughtworks.xstream.XStream.processAnnotations(XStream.java:1451)
at com.thoughtworks.acceptance.annotations.MapConverterTest.setUp(MapConverterTest.java:42)
Below is a new testcase for the above reported problem
Index:
/home/chungonn/development/projects/xstream-trunk/xstream/src/test/com/thoughtworks/acceptance/annotations/MapConverterTest.java
===================================================================
/home/chungonn/development/projects/xstream-trunk/xstream/src/test/com/thoughtworks/acceptance/annotations/MapConverterTest.java
(revision 0)
+++
/home/chungonn/development/projects/xstream-trunk/xstream/src/test/com/thoughtworks/acceptance/annotations/MapConverterTest.java
(revision 0)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2006 Joe Walnes.
+ * Copyright (C) 2006, 2007 XStream Committers.
+ * All rights reserved.
+ *
+ * The software in this package is published under the terms of the BSD
+ * style license a copy of which has been included with this distribution in
+ * the LICENSE.txt file.
+ *
+ * Created on 02. March 2006 by Mauro Talevi
+ */
+package com.thoughtworks.acceptance.annotations;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.thoughtworks.acceptance.AbstractAcceptanceTest;
+import com.thoughtworks.xstream.XStream;
+import com.thoughtworks.xstream.annotations.XStreamConverter;
+import com.thoughtworks.xstream.annotations.XStreamConverters;
+import com.thoughtworks.xstream.converters.collections.MapConverter;
+import com.thoughtworks.xstream.mapper.Mapper;
+
+
+/**
+ * Tests for using annotations to map converter
+ *
+ * @author Chung-Onn, Cheong
+ */
+public class MapConverterTest extends AbstractAcceptanceTest {
+ + @Override
+ protected XStream createXStream()
+
+ protected void setUp() throws Exception
+
+ public void testAnnotationForForFieldsOfSameType()
+
+ @XStreamConverters(
)
+ public class MyMap extends HashMap<String, Object>
+ + public class MyMapConverter extends MapConverter {
+
+ public MyMapConverter(Mapper classMapper)
+ + public boolean canConvert(Class type)
{ + return type.equals(Map.class); + }+
+ }
+}
TestCase for MapConverter