Search in sources :

Example 1 with XmlMappedAttributeBean

use of org.apache.cxf.aegis.services.XmlMappedAttributeBean in project cxf by apache.

the class QualificationTest method testXmlDefaultQualifiedAttribute.

@Test
public void testXmlDefaultQualifiedAttribute() throws Exception {
    AegisContext context = new AegisContext();
    TypeCreationOptions typeCreationOptions = new TypeCreationOptions();
    typeCreationOptions.setQualifyAttributes(true);
    context.setTypeCreationOptions(typeCreationOptions);
    context.initialize();
    TypeMapping mapping = context.getTypeMapping();
    AegisType type = mapping.getTypeCreator().createType(XmlMappedAttributeBean.class);
    type.setSchemaType(new QName("urn:Bean", "bean"));
    Context messageContext = new Context(context);
    XmlMappedAttributeBean bean = new XmlMappedAttributeBean();
    Element element = writeObjectToElement(type, bean, messageContext);
    assertValid("/b:root[@pkg:attrXmlString]", element);
    assertXPathEquals("/b:root/@pkg:attrXmlString", "attrXml", element);
}
Also used : Context(org.apache.cxf.aegis.Context) AegisContext(org.apache.cxf.aegis.AegisContext) XmlMappedAttributeBean(org.apache.cxf.aegis.services.XmlMappedAttributeBean) AegisType(org.apache.cxf.aegis.type.AegisType) QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element) AegisContext(org.apache.cxf.aegis.AegisContext) TypeMapping(org.apache.cxf.aegis.type.TypeMapping) TypeCreationOptions(org.apache.cxf.aegis.type.TypeCreationOptions) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 2 with XmlMappedAttributeBean

use of org.apache.cxf.aegis.services.XmlMappedAttributeBean in project cxf by apache.

the class QualificationTest method testXmlDefaultUnqualifiedAttribute.

@Test
public void testXmlDefaultUnqualifiedAttribute() throws Exception {
    AegisContext context = new AegisContext();
    context.initialize();
    TypeMapping mapping = context.getTypeMapping();
    AegisType type = mapping.getTypeCreator().createType(XmlMappedAttributeBean.class);
    type.setSchemaType(new QName("urn:Bean", "bean"));
    Context messageContext = new Context(context);
    XmlMappedAttributeBean bean = new XmlMappedAttributeBean();
    Element element = writeObjectToElement(type, bean, messageContext);
    assertValid("/b:root[@attrXmlString]", element);
    assertXPathEquals("/b:root/@attrXmlString", "attrXml", element);
}
Also used : Context(org.apache.cxf.aegis.Context) AegisContext(org.apache.cxf.aegis.AegisContext) XmlMappedAttributeBean(org.apache.cxf.aegis.services.XmlMappedAttributeBean) AegisType(org.apache.cxf.aegis.type.AegisType) QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element) AegisContext(org.apache.cxf.aegis.AegisContext) TypeMapping(org.apache.cxf.aegis.type.TypeMapping) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Aggregations

QName (javax.xml.namespace.QName)2 AbstractAegisTest (org.apache.cxf.aegis.AbstractAegisTest)2 AegisContext (org.apache.cxf.aegis.AegisContext)2 Context (org.apache.cxf.aegis.Context)2 XmlMappedAttributeBean (org.apache.cxf.aegis.services.XmlMappedAttributeBean)2 AegisType (org.apache.cxf.aegis.type.AegisType)2 TypeMapping (org.apache.cxf.aegis.type.TypeMapping)2 Test (org.junit.Test)2 Element (org.w3c.dom.Element)2 TypeCreationOptions (org.apache.cxf.aegis.type.TypeCreationOptions)1