JsonXMLRootProvider { protected String getNamespaceURI(XmlType xmlType, XmlSchema xmlSchema) { if ("##default".equals(xmlType.namespace())) { return xmlSchema == null ? XMLConstants.NULL_NS_URI : xmlSchema.namespace(); } else { return xmlType.namespace(); } }  QName getName(Class<?> type); JAXBElement<?> createElement(Class<?> type, Object value);  }
@Test public void testGetNamespaceURI_XmlRootElement() { JsonXMLRootProvider provider = new JsonXMLRootProvider(); Assert.assertEquals(XMLConstants.NULL_NS_URI, provider.getNamespaceURI(SampleRootElement.class.getAnnotation(XmlRootElement.class), null)); }
@Test public void testGetNamespaceURI_XmlType() { JsonXMLRootProvider provider = new JsonXMLRootProvider(); Assert.assertEquals(XMLConstants.NULL_NS_URI, provider.getNamespaceURI(SampleType.class.getAnnotation(XmlType.class), null)); Assert.assertEquals("urn:staxon:jaxb:test", provider.getNamespaceURI(SampleTypeWithNamespace.class.getAnnotation(XmlType.class), null)); }
@Test public void testGetNamespaceURI_XmlElementDecl() throws Exception { JsonXMLRootProvider provider = new JsonXMLRootProvider(); Method createSampleType = ObjectFactory.class.getMethod("createSampleType", SampleType.class); Assert.assertEquals(XMLConstants.NULL_NS_URI, provider.getNamespaceURI(createSampleType.getAnnotation(XmlElementDecl.class), null)); Method createSampleTypeWithNamespace = ObjectFactory.class.getMethod("createSampleTypeWithNamespace", SampleTypeWithNamespace.class); Assert.assertEquals("urn:staxon:jaxb:test", provider.getNamespaceURI(createSampleTypeWithNamespace.getAnnotation(XmlElementDecl.class), null)); }