### Question:
JAXBExtensionHelper implements ExtensionSerializer, ExtensionDeserializer { public static void addExtensions(ExtensionRegistry registry, String parentType, String elementType) throws JAXBException, ClassNotFoundException { Class<?> parentTypeClass = ClassLoaderUtils.loadClass(parentType, JAXBExtensionHelper.class); Class<? extends ExtensibilityElement> elementTypeClass = ClassLoaderUtils.loadClass(elementType, JAXBExtensionHelper.class) .asSubclass(ExtensibilityElement.class); addExtensions(registry, parentTypeClass, elementTypeClass, null); } JAXBExtensionHelper(Class<?> cls,
                               String ns); static void addExtensions(ExtensionRegistry registry, String parentType, String elementType); static void addExtensions(ExtensionRegistry registry,
                                     String parentType,
                                     String elementType,
                                     String namespace); static void addExtensions(ExtensionRegistry registry,
                                     Class<?> parentType,
                                     Class<?> cls); static void addExtensions(ExtensionRegistry registry,
                                     Class<?> parentType,
                                     Class<?> cls,
                                     String namespace); static void addExtensions(ExtensionRegistry registry,
                                     Class<?> parentType,
                                     Class<?> cls,
                                     String namespace,
                                     ClassLoader loader); void marshall(@SuppressWarnings("rawtypes") Class parent, QName qname,
                         ExtensibilityElement obj, PrintWriter pw,
                         final Definition wsdl, ExtensionRegistry registry); ExtensibilityElement unmarshall(@SuppressWarnings("rawtypes") Class parent,
                                           QName qname, Element element, Definition wsdl,
                                           ExtensionRegistry registry);  }### Answer:
@Test public void testAddTestExtension() throws Exception { JAXBExtensionHelper.addExtensions(registry, "javax.wsdl.Port", "org.apache.cxf.abc.test.TestPolicyType"); JAXBExtensionHelper.addExtensions(registry, "javax.wsdl.Port", "org.apache.cxf.abc.test.AnotherPolicyType"); JAXBExtensionHelper.addExtensions(registry, "javax.wsdl.Definition", "org.apache.cxf.abc.test.NewServiceType"); String file = this.getClass().getResource("/wsdl/test_ext.wsdl").toURI().toString(); wsdlReader.setExtensionRegistry(registry); wsdlDefinition = wsdlReader.readWSDL(file); checkTestExt(); }
@Test public void testMappedNamespace() throws Exception { JAXBExtensionHelper.addExtensions(registry, javax.wsdl.Port.class, org.apache.cxf.abc.test.TestPolicyType.class, "http: JAXBExtensionHelper.addExtensions(registry, javax.wsdl.Port.class, org.apache.cxf.abc.test.AnotherPolicyType.class, "http: JAXBExtensionHelper.addExtensions(registry, javax.wsdl.Definition.class, org.apache.cxf.abc.test.NewServiceType.class, "http: String file = this.getClass().getResource("/wsdl/test_ext_remapped.wsdl").toURI().toString(); wsdlReader.setExtensionRegistry(registry); wsdlDefinition = wsdlReader.readWSDL(file); checkTestExt(); StringWriter out = new StringWriter(); wsdlFactory.newWSDLWriter().writeWSDL(wsdlDefinition, out); wsdlDefinition = wsdlReader.readWSDL(null, new InputSource(new StringReader(out.toString()))); checkTestExt(); }