Search in sources :

Example 1 with AttributeBean

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

the class QualificationTest method testAnnotatedDefaultQualifiedAttribute.

@Test
public void testAnnotatedDefaultQualifiedAttribute() 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(AttributeBean.class);
    type.setSchemaType(new QName("urn:Bean", "bean"));
    Context messageContext = new Context(context);
    AttributeBean bean = new AttributeBean();
    Element element = writeObjectToElement(type, bean, messageContext);
    assertValid("/b:root[@xyzzy:attrExplicitString]", element);
    assertXPathEquals("/b:root/@xyzzy:attrExplicitString", "attrExplicit", element);
    assertValid("/b:root[@pkg:attrPlainString]", element);
    assertXPathEquals("/b:root/@pkg:attrPlainString", "attrPlain", element);
}
Also used : Context(org.apache.cxf.aegis.Context) AegisContext(org.apache.cxf.aegis.AegisContext) 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) XmlMappedAttributeBean(org.apache.cxf.aegis.services.XmlMappedAttributeBean) AttributeBean(org.apache.cxf.aegis.services.AttributeBean) TypeCreationOptions(org.apache.cxf.aegis.type.TypeCreationOptions) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 2 with AttributeBean

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

the class QualificationTest method testAnnotatedDefaultUnqualifiedAttribute.

@Test
public void testAnnotatedDefaultUnqualifiedAttribute() throws Exception {
    AegisContext context = new AegisContext();
    context.initialize();
    TypeMapping mapping = context.getTypeMapping();
    AegisType type = mapping.getTypeCreator().createType(AttributeBean.class);
    type.setSchemaType(new QName("urn:Bean", "bean"));
    Context messageContext = new Context(context);
    AttributeBean bean = new AttributeBean();
    Element element = writeObjectToElement(type, bean, messageContext);
    assertValid("/b:root[@xyzzy:attrExplicitString]", element);
    assertXPathEquals("/b:root/@xyzzy:attrExplicitString", "attrExplicit", element);
    assertValid("/b:root[@attrPlainString]", element);
    assertXPathEquals("/b:root/@attrPlainString", "attrPlain", element);
}
Also used : Context(org.apache.cxf.aegis.Context) AegisContext(org.apache.cxf.aegis.AegisContext) 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) XmlMappedAttributeBean(org.apache.cxf.aegis.services.XmlMappedAttributeBean) AttributeBean(org.apache.cxf.aegis.services.AttributeBean) 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 AttributeBean (org.apache.cxf.aegis.services.AttributeBean)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