package hudson.util;

import junit.framework.TestCase;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.converters.ConversionException;

/**
 * @author Kohsuke Kawaguchi
 */
public class RobustReflectionConverterTest extends TestCase {

    public void testRobustUnmarshalling() {
        Point p = read(new XStream2());
        assertEquals(p.x,1);
        assertEquals(p.y,2);
    }

    private Point read(XStream xs) {
        String clsName = Point.class.getName();
        return (Point) xs.fromXML("<" + clsName + "><x>1</x><y>2</y><z>3</z></" + clsName + '>');
    }

    public void testIfWeNeedWorkaround() {
        try {
            read(new XStream());
            fail();
        } catch (ConversionException e) {
            // expected
            assertTrue(e.getMessage().contains("z"));
        }
    }
}

@@ -152,16 +152,81 @@
 ception;
+%0Aimport java.util.logging.Level;%0Aimport java.util.logging.Logger;
 %0A%0A/**%0A *
@@ -319,16 +319,125 @@
 Case %7B%0A%0A
+    static %7B%0A        Logger.getLogger(RobustReflectionConverter.class.getName()).setLevel(Level.OFF);%0A    %7D%0A%0A
     publ

Avoid printing a stack trace when the test is in fact passing.