Search in sources :

Example 11 with AegisContext

use of org.apache.cxf.aegis.AegisContext 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 12 with AegisContext

use of org.apache.cxf.aegis.AegisContext 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)

Example 13 with AegisContext

use of org.apache.cxf.aegis.AegisContext in project cxf by apache.

the class AbstractEncodedTest method getContext.

protected Context getContext() {
    AegisContext globalContext = new AegisContext();
    globalContext.initialize();
    globalContext.setTypeMapping(mapping);
    return new Context(globalContext);
}
Also used : MapNamespaceContext(org.apache.cxf.helpers.MapNamespaceContext) Context(org.apache.cxf.aegis.Context) AegisContext(org.apache.cxf.aegis.AegisContext) AegisContext(org.apache.cxf.aegis.AegisContext)

Example 14 with AegisContext

use of org.apache.cxf.aegis.AegisContext in project cxf by apache.

the class ArrayTypeInfoTest method setUp.

public void setUp() throws Exception {
    super.setUp();
    addNamespace("b", "urn:Bean");
    addNamespace("a", "urn:anotherns");
    addNamespace("xsi", Constants.URI_2001_SCHEMA_XSI);
    AegisContext context = new AegisContext();
    context.initialize();
    mapping = context.getTypeMapping();
    // address type
    BeanTypeInfo addressInfo = new BeanTypeInfo(Address.class, "urn:Bean");
    addressInfo.setTypeMapping(mapping);
    addressType = new StructType(addressInfo);
    addressType.setTypeClass(Address.class);
    addressType.setSchemaType(new QName("urn:Bean", "addr"));
    mapping.register(addressType);
}
Also used : BeanTypeInfo(org.apache.cxf.aegis.type.basic.BeanTypeInfo) QName(javax.xml.namespace.QName) AegisContext(org.apache.cxf.aegis.AegisContext)

Example 15 with AegisContext

use of org.apache.cxf.aegis.AegisContext in project cxf by apache.

the class ClassTest method startServer.

@Before
public void startServer() throws Exception {
    AegisContext context = new AegisContext();
    context.initialize();
    context.getTypeMapping().register(new ClassAsStringType());
    ServerFactoryBean b = new ServerFactoryBean();
    b.setDataBinding(new AegisDatabinding(context));
    b.setServiceClass(GenericsService.class);
    b.setAddress("local://GenericsService");
    server = b.create();
}
Also used : AegisContext(org.apache.cxf.aegis.AegisContext) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) AegisDatabinding(org.apache.cxf.aegis.databinding.AegisDatabinding) Before(org.junit.Before)

Aggregations

AegisContext (org.apache.cxf.aegis.AegisContext)40 Test (org.junit.Test)20 QName (javax.xml.namespace.QName)15 AegisType (org.apache.cxf.aegis.type.AegisType)15 HashSet (java.util.HashSet)13 XMLStreamReader (javax.xml.stream.XMLStreamReader)8 AbstractAegisTest (org.apache.cxf.aegis.AbstractAegisTest)8 TypeMapping (org.apache.cxf.aegis.type.TypeMapping)8 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)6 Context (org.apache.cxf.aegis.Context)6 TypeCreationOptions (org.apache.cxf.aegis.type.TypeCreationOptions)6 XmlSchema (org.apache.ws.commons.schema.XmlSchema)5 Before (org.junit.Before)5 StringWriter (java.io.StringWriter)4 AegisDatabinding (org.apache.cxf.aegis.databinding.AegisDatabinding)4 XmlMappedAttributeBean (org.apache.cxf.aegis.services.XmlMappedAttributeBean)4 Type (java.lang.reflect.Type)3 ArrayList (java.util.ArrayList)3 SimpleBean (org.apache.cxf.aegis.services.SimpleBean)3 DefaultTypeMapping (org.apache.cxf.aegis.type.DefaultTypeMapping)3