use of org.apache.cxf.common.util.ASMHelperImpl in project cxf by apache.
the class JAXBDataBindingTest method testClassInDefaultPackage.
@Test
public void testClassInDefaultPackage() throws Exception {
Class<?> sampleClassInDefaultPackage = Class.forName("SampleClassInDefaultPackage");
Set<Class<?>> classes = new HashSet<>();
Collection<Object> typeReferences = new ArrayList<>();
Map<String, Object> props = new HashMap<>();
Bus b = new ExtensionManagerBus();
b.setExtension(new ASMHelperImpl(), ASMHelper.class);
FactoryClassCreator extr = new FactoryClassProxyService(b);
b.setExtension(extr, FactoryClassCreator.class);
JAXBContextInitializer init = new JAXBContextInitializer(b, null, classes, typeReferences, props);
init.addClass(sampleClassInDefaultPackage);
assertEquals(1, classes.size());
}
use of org.apache.cxf.common.util.ASMHelperImpl in project cxf by apache.
the class JAXBDataBindingTest method doNamespaceMappingTest.
void doNamespaceMappingTest(boolean internal, boolean asm) throws Exception {
if (internal) {
try {
Class.forName("com.sun.xml.internal.bind.v2.ContextFactory");
} catch (Throwable t) {
// on a JVM (likely IBM's) that doesn't rename the ContextFactory package to include "internal"
return;
}
}
Bus b = new ExtensionManagerBus();
ASMHelper helper = new ASMHelperImpl();
b.setExtension(helper, ASMHelper.class);
FactoryClassCreator extr = new FactoryClassProxyService(b);
b.setExtension(extr, FactoryClassCreator.class);
try {
if (!asm) {
ReflectionUtil.setAccessible(ReflectionUtil.getDeclaredField(ASMHelperImpl.class, "badASM")).set(helper, Boolean.TRUE);
}
JAXBDataBinding db = createJaxbContext(internal);
DataWriter<XMLStreamWriter> writer = db.createWriter(XMLStreamWriter.class);
XMLOutputFactory writerFactory = XMLOutputFactory.newInstance();
StringWriter stringWriter = new StringWriter();
XMLStreamWriter xmlWriter = writerFactory.createXMLStreamWriter(stringWriter);
QualifiedBean bean = new QualifiedBean();
bean.setAriadne("spider");
writer.write(bean, xmlWriter);
xmlWriter.flush();
String xml = stringWriter.toString();
assertTrue("Failed to map namespace " + xml, xml.contains("greenland=\"uri:ultima:thule"));
} finally {
if (!asm) {
ReflectionUtil.setAccessible(ReflectionUtil.getDeclaredField(ASMHelperImpl.class, "badASM")).set(helper, Boolean.FALSE);
}
}
}
use of org.apache.cxf.common.util.ASMHelperImpl in project cxf by apache.
the class JAXBDataBindingTest method testResursiveType.
@Test
public void testResursiveType() throws Exception {
Set<Class<?>> classes = new HashSet<>();
Collection<Object> typeReferences = new ArrayList<>();
Map<String, Object> props = new HashMap<>();
Bus b = new ExtensionManagerBus();
b.setExtension(new ASMHelperImpl(), ASMHelper.class);
FactoryClassCreator extr = new FactoryClassProxyService(b);
b.setExtension(extr, FactoryClassCreator.class);
JAXBContextInitializer init = new JAXBContextInitializer(b, null, classes, typeReferences, props);
init.addClass(Type2.class);
assertEquals(2, classes.size());
}
use of org.apache.cxf.common.util.ASMHelperImpl in project cxf by apache.
the class JAXBExtensionHelperTest method setUp.
@Before
public void setUp() throws Exception {
wsdlFactory = WSDLFactory.newInstance();
wsdlReader = wsdlFactory.newWSDLReader();
wsdlReader.setFeature("javax.wsdl.verbose", false);
registry = wsdlReader.getExtensionRegistry();
if (registry == null) {
registry = wsdlFactory.newPopulatedExtensionRegistry();
}
bus = new ExtensionManagerBus();
bus.setExtension(new ASMHelperImpl(), ASMHelper.class);
ExtensionClassCreator extr = new ExtensionClassGenerator(bus);
bus.setExtension(extr, ExtensionClassCreator.class);
}
Aggregations