@Test
public void configureComplexWithPropertyNotFoundExceptionEnsureOnlyOnePropertyChanged() throws Exception {

    // build xml
    StringBuilder string0 = new StringBuilder(200)
            .append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n")
            .append("<configuration>\n")
            .append("   <url>http://www.google.com/</url>\n")
            .append("   <server>\n")
            .append("     <host>www2.google.com</host>\n")      // this should be changed since server reference already existed
            .append("     <port2>80</port2>\n")                 // this should cause an error to be thrown
            .append("   </server>\n")
            .append("</configuration>")
            .append("");
    // parse xml
    ByteArrayInputStream is = new ByteArrayInputStream(string0.toString().getBytes());
    XmlParser parser = new XmlParser();
    XmlParser.Node rootNode = parser.parse(is);
    // object we'll configure
    ComplexConfiguration config = new ComplexConfiguration();
    Server server = new Server();
    config.setServer(server);
    server.setHost("www.google.com");
    server.setPort(443);
    // configure it using default options
    XmlBean bean = new XmlBean();
    try {
        bean.configure(rootNode, config);
        Assert.fail("Configure should have failed");
    } catch (XmlBeanException e) {
        // ignore it
    }
    // server should remain the same
    Assert.assertSame(server, config.getServer());
    Assert.assertEquals("http://www.google.com/", config.url);
    Assert.assertEquals(443, config.getServer().port);
    // this property should have changed since "server" was already stored in main config object
    Assert.assertEquals("www2.google.com", config.getServer().host);
}