Search in sources :

Example 36 with AegisContext

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

Example 37 with AegisContext

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

the class AbstractEncodedTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    addNamespace("b", "urn:Bean");
    addNamespace("a", "urn:anotherns");
    addNamespace("xsi", Constants.URI_2001_SCHEMA_XSI);
    addNamespace("soapenc", Soap11.getInstance().getSoapEncodingStyle());
    AegisContext context = new AegisContext();
    // create a different mapping than the context creates.
    TypeMapping baseMapping = DefaultTypeMapping.createSoap11TypeMapping(true, false, false);
    mapping = new DefaultTypeMapping(Constants.URI_2001_SCHEMA_XSD, baseMapping);
    mapping.setTypeCreator(context.createTypeCreator());
    context.setTypeMapping(mapping);
    context.initialize();
    // serialization root type
    trailingBlocks = new TrailingBlocks();
}
Also used : DefaultTypeMapping(org.apache.cxf.aegis.type.DefaultTypeMapping) AegisContext(org.apache.cxf.aegis.AegisContext) DefaultTypeMapping(org.apache.cxf.aegis.type.DefaultTypeMapping) TypeMapping(org.apache.cxf.aegis.type.TypeMapping) Before(org.junit.Before)

Example 38 with AegisContext

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

the class CustomMappingTest method testInheritedMapping.

@Test
public void testInheritedMapping() throws Exception {
    BeanTypeInfo bti = new BeanTypeInfo(GregorianCalendar.class, "http://util.java");
    BeanType beanType = new BeanType(bti);
    beanType.setSchemaType(new QName("http://util.java{GregorianCalendar}"));
    AegisContext context = new AegisContext();
    context.initialize();
    TypeMapping mapping = context.getTypeMapping();
    // we are replacing the default mapping.
    mapping.register(beanType);
    XmlSchema schema = newXmlSchema("http://util.java");
    beanType.writeSchema(schema);
// well, test?
}
Also used : BeanTypeInfo(org.apache.cxf.aegis.type.basic.BeanTypeInfo) BeanType(org.apache.cxf.aegis.type.basic.BeanType) XmlSchema(org.apache.ws.commons.schema.XmlSchema) QName(javax.xml.namespace.QName) AegisContext(org.apache.cxf.aegis.AegisContext) TypeMapping(org.apache.cxf.aegis.type.TypeMapping) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 39 with AegisContext

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

the class ExceptionInheritanceTest method setUp.

public void setUp() throws Exception {
    super.setUp();
    AegisContext globalContext = new AegisContext();
    globalContext.setWriteXsiTypes(true);
    Set<String> l = new HashSet<>();
    l.add(SimpleBean.class.getName());
    l.add(WS1ExtendedException.class.getName());
    globalContext.setRootClassNames(l);
    AegisDatabinding binding = new AegisDatabinding();
    binding.setAegisContext(globalContext);
    ClientProxyFactoryBean pf = new ClientProxyFactoryBean();
    setupAegis(pf.getClientFactoryBean(), binding);
    pf.getServiceFactory().setProperties(props);
    pf.setAddress("local://WS1");
    pf.setProperties(props);
    client = pf.create(WS1.class);
    Server server = createService(WS1.class, new WS1Impl(), "WS1", binding);
    server.getEndpoint().getService().setInvoker(new BeanInvoker(new WS1Impl()));
}
Also used : WS1Impl(org.apache.cxf.aegis.inheritance.ws1.impl.WS1Impl) WS1(org.apache.cxf.aegis.inheritance.ws1.WS1) Server(org.apache.cxf.endpoint.Server) SimpleBean(org.apache.cxf.aegis.services.SimpleBean) ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) BeanInvoker(org.apache.cxf.service.invoker.BeanInvoker) AegisContext(org.apache.cxf.aegis.AegisContext) AegisDatabinding(org.apache.cxf.aegis.databinding.AegisDatabinding) WS1ExtendedException(org.apache.cxf.aegis.inheritance.ws1.WS1ExtendedException) HashSet(java.util.HashSet)

Example 40 with AegisContext

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

the class InheritancePOJOTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    ServerFactoryBean sf = createServiceFactory(InheritanceService.class, null, "InheritanceService", new QName("urn:xfire:inheritance", "InheritanceService"), null);
    AegisContext globalContext = new AegisContext();
    globalContext.setWriteXsiTypes(true);
    Set<String> l = new HashSet<>();
    l.add(Employee.class.getName());
    globalContext.setRootClassNames(l);
    AegisDatabinding binding = new AegisDatabinding();
    binding.setAegisContext(globalContext);
    sf.getServiceFactory().setDataBinding(binding);
    sf.create();
}
Also used : QName(javax.xml.namespace.QName) AegisContext(org.apache.cxf.aegis.AegisContext) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) AegisDatabinding(org.apache.cxf.aegis.databinding.AegisDatabinding) HashSet(java.util.HashSet) 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