use of org.apache.cxf.aegis.AegisContext in project tutorials by eugenp.
the class BaeldungIntegrationTest method initializeContext.
private void initializeContext() {
context = new AegisContext();
Set<Type> rootClasses = new HashSet<Type>();
rootClasses.add(CourseRepo.class);
context.setRootClasses(rootClasses);
Map<Class<?>, String> beanImplementationMap = new HashMap<>();
beanImplementationMap.put(CourseRepoImpl.class, "CourseRepo");
context.setBeanImplementationMap(beanImplementationMap);
context.setWriteXsiTypes(true);
context.initialize();
}
use of org.apache.cxf.aegis.AegisContext in project cxf by apache.
the class BeanTest method testNillableIntMinOccurs1.
@Test
public void testNillableIntMinOccurs1() throws Exception {
context = new AegisContext();
TypeCreationOptions config = new TypeCreationOptions();
config.setDefaultMinOccurs(1);
config.setDefaultNillable(false);
context.setTypeCreationOptions(config);
context.initialize();
mapping = context.getTypeMapping();
BeanType type = (BeanType) mapping.getTypeCreator().createType(IntBean.class);
type.setTypeClass(IntBean.class);
type.setTypeMapping(mapping);
XmlSchema schema = newXmlSchema("urn:Bean");
type.writeSchema(schema);
XmlSchemaComplexType btype = (XmlSchemaComplexType) schema.getTypeByName("IntBean");
XmlSchemaSequence seq = (XmlSchemaSequence) btype.getParticle();
boolean int1ok = false;
for (int x = 0; x < seq.getItems().size(); x++) {
XmlSchemaSequenceMember o = seq.getItems().get(x);
if (o instanceof XmlSchemaElement) {
XmlSchemaElement oe = (XmlSchemaElement) o;
if ("int1".equals(oe.getName())) {
int1ok = true;
assertFalse(oe.isNillable());
assertEquals(1, oe.getMinOccurs());
}
}
}
assertTrue(int1ok);
}
use of org.apache.cxf.aegis.AegisContext in project cxf by apache.
the class BeanTest method defaultContext.
private void defaultContext() {
context = new AegisContext();
context.initialize();
mapping = context.getTypeMapping();
}
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);
}
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);
}
Aggregations