use of org.apache.cxf.aegis.type.AegisType in project cxf by apache.
the class EnumTypeTest method testTypeWithJaxbAnnotations.
/**
* {@link https://issues.apache.org/jira/browse/CXF-7188}
*/
@Test
public void testTypeWithJaxbAnnotations() throws Exception {
AegisType type = tm.getTypeCreator().createType(JaxbTestEnum.class);
Element element = writeObjectToElement(type, JaxbTestEnum.VALUE1, getContext());
assertEquals("Value1", element.getTextContent());
XMLStreamReader xreader = StaxUtils.createXMLStreamReader(element);
ElementReader reader = new ElementReader(xreader);
Object value = type.readObject(reader, getContext());
assertEquals(JaxbTestEnum.VALUE1, value);
}
use of org.apache.cxf.aegis.type.AegisType in project cxf by apache.
the class EnumTypeTest method testJaxbTypeAttributeOnEnum.
@Test
public void testJaxbTypeAttributeOnEnum() throws Exception {
AegisType type = tm.getTypeCreator().createType(JaxbTestEnum.class);
assertEquals("urn:xfire:foo", type.getSchemaType().getNamespaceURI());
assertTrue(type instanceof EnumType);
}
use of org.apache.cxf.aegis.type.AegisType in project cxf by apache.
the class EnumTypeTest method testWsdlFromJaxbAnnotations.
/**
* {@link https://issues.apache.org/jira/browse/CXF-7188}
*/
@Test
public void testWsdlFromJaxbAnnotations() throws Exception {
AegisType type = tm.getTypeCreator().createType(JaxbTestEnum.class);
XmlSchema schema = newXmlSchema("urn:test");
type.writeSchema(schema);
XmlSchemaSerializer ser = new XmlSchemaSerializer();
Document doc = ser.serializeSchema(schema, false)[0];
addNamespace("xsd", Constants.URI_2001_SCHEMA_XSD);
assertValid("//xsd:simpleType[@name='bar']/xsd:restriction[@base='xsd:string']", doc);
assertValid("//xsd:restriction[@base='xsd:string']/xsd:enumeration[@value='Value1']", doc);
assertValid("//xsd:restriction[@base='xsd:string']/xsd:enumeration[@value='VALUE2']", doc);
}
use of org.apache.cxf.aegis.type.AegisType 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);
}
use of org.apache.cxf.aegis.type.AegisType 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);
}
Aggregations