@Test
public void testXmlBeans() throws Exception {
mapper = getMapper(new String[] { "xmlBeansMapping.xml" });
// Map from TestObject to XMLBeans
TestObject to = (TestObject) newInstance(TestObject.class);
to.setOne("one");
GetWeatherByZipCodeDocument doc = mapper.map(to, GetWeatherByZipCodeDocument.class);
assertEquals(to.getOne(), doc.getGetWeatherByZipCode().getZipCode());
// Map from XMLBeans to TestObject
GetWeatherByZipCodeDocument res = GetWeatherByZipCodeDocument.Factory.newInstance();
GetWeatherByZipCode zipCode = res.addNewGetWeatherByZipCode();
zipCode.setZipCode("one");
TestObject to2 = mapper.map(res, TestObject.class);
assertEquals(res.getGetWeatherByZipCode().getZipCode(), to2.getOne());
Set set = new HashSet();
AnotherTestObject ato = new AnotherTestObject();
ato.setDay("day");
set.add(ato);
to.setSetToArray(set);
AnotherTestObject ato2 = new AnotherTestObject();
ato2.setDay("day");
to.addAnotherTestObject(ato2);
GetWeatherByZipCodeResponseDocument responseDoc = mapper.map(to, GetWeatherByZipCodeResponseDocument.class);
WeatherData[] weatherDataArray = responseDoc.getGetWeatherByZipCodeResponse().getWeatherDataArray();
WeatherData[] weatherData2Array = responseDoc.getGetWeatherByZipCodeResponse().getWeatherData2Array();
assertEquals(ato.getDay(), weatherDataArray[0].getDay());
assertEquals(ato2.getDay(), weatherData2Array[0].getDay());
// now take the xmlbeans array and map the other direction
TestObject toResult = mapper.map(responseDoc, TestObject.class);
assertEquals(weatherDataArray[0].getDay(), ((AnotherTestObject) toResult.getSetToArray().iterator().next()).getDay());
assertEquals(weatherData2Array[0].getDay(), ((AnotherTestObject) toResult.getSetToArrayWithIterate().iterator().next())
.getDay());
}