InitialContextInfo implements Serializable { public List<Property> getContextProperty() { if (contextProperty==null) { contextProperty = new ArrayList<Property>(); } return contextProperty; } InitialContextInfo(); List<Property> getContextProperty(); void setProperty(List<Property> contextProperty);  }
@Test public void initialContextInfo_XML2JAVA() { try { String INITIAL_CONTEXT_XML = "<initialContextInfo>" + "<contextProperty value=\"value1\" name=\"name1\"/>" + "<contextProperty value=\"value2\" name=\"name2\"/>" + "</initialContextInfo>"; StringReader reader = new StringReader(INITIAL_CONTEXT_XML); JAXBContext jc = JAXBContext.newInstance(InitialContextInfo.class); Unmarshaller um = jc.createUnmarshaller(); InitialContextInfo icInfo = (InitialContextInfo) um.unmarshal(new StreamSource(reader), InitialContextInfo.class).getValue(); assertEquals("name1", icInfo.getContextProperty().get(0).getName()); assertEquals("name2", icInfo.getContextProperty().get(1).getName()); assertEquals("value2", icInfo.getContextProperty().get(1).getValue()); } catch (JAXBException jaxbe) { jaxbe.printStackTrace(); fail("No exception should be thrown"); } }
@Test public void bindingTemplate_XML2JAVA() { try { String instanceDetailsStr = "<instanceDetails xmlns=\"urn:uddi-org:api_v3\">" + "<instanceParms><![CDATA[ " + "<initialContextInfo>" + "<contextProperty value=\"value1\" name=\"name1\"/>" + "<contextProperty value=\"value2\" name=\"name2\"/>" + "</initialContextInfo> ]]>" + "</instanceParms>" + "</instanceDetails>"; InstanceDetails details = (InstanceDetails) JAXBMarshaller.unmarshallFromString(instanceDetailsStr,JAXBMarshaller.PACKAGE_UDDIAPI); String instanceParmsStr = details.getInstanceParms(); if (instanceParmsStr!=null) { InitialContextInfo icInfo = (InitialContextInfo) JAXBMarshaller.unmarshallFromString(instanceParmsStr, JAXBMarshaller.PACKAGE_JUDDI); assertEquals("name1" , icInfo.getContextProperty().get(0).getName()); assertEquals("name2" , icInfo.getContextProperty().get(1).getName()); assertEquals("value2", icInfo.getContextProperty().get(1).getValue()); } else { fail("We should have data in instanceParmsStr."); } } catch (JAXBException jaxbe) { jaxbe.printStackTrace(); fail("No exception should be thrown"); } }