Search in sources :

Example 46 with AegisType

use of org.apache.cxf.aegis.type.AegisType in project cxf by apache.

the class ConfigurationTest method testMinOccursDefault1.

@Test
public void testMinOccursDefault1() throws Exception {
    config.setDefaultMinOccurs(1);
    AegisType type = tm.getTypeCreator().createType(AnnotatedBean1.class);
    BeanTypeInfo info = ((BeanType) type).getTypeInfo();
    assertEquals(info.getMinOccurs(new QName(info.getDefaultNamespace(), "bogusProperty")), 1);
}
Also used : BeanTypeInfo(org.apache.cxf.aegis.type.basic.BeanTypeInfo) AegisType(org.apache.cxf.aegis.type.AegisType) BeanType(org.apache.cxf.aegis.type.basic.BeanType) QName(javax.xml.namespace.QName) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 47 with AegisType

use of org.apache.cxf.aegis.type.AegisType in project cxf by apache.

the class ConfigurationTest method testMinOccursDefault0.

@Test
public void testMinOccursDefault0() throws Exception {
    config.setDefaultMinOccurs(0);
    AegisType type = tm.getTypeCreator().createType(AnnotatedBean1.class);
    BeanTypeInfo info = ((BeanType) type).getTypeInfo();
    assertEquals(info.getMinOccurs(new QName(info.getDefaultNamespace(), "bogusProperty")), 0);
}
Also used : BeanTypeInfo(org.apache.cxf.aegis.type.basic.BeanTypeInfo) AegisType(org.apache.cxf.aegis.type.AegisType) BeanType(org.apache.cxf.aegis.type.basic.BeanType) QName(javax.xml.namespace.QName) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 48 with AegisType

use of org.apache.cxf.aegis.type.AegisType in project cxf by apache.

the class ConfigurationTest method testExtensibleDefaultFalse.

@Test
public void testExtensibleDefaultFalse() throws Exception {
    config.setDefaultExtensibleElements(false);
    config.setDefaultExtensibleAttributes(false);
    AegisType type = tm.getTypeCreator().createType(AnnotatedBean1.class);
    BeanTypeInfo info = ((BeanType) type).getTypeInfo();
    assertFalse(info.isExtensibleElements());
    assertFalse(info.isExtensibleAttributes());
}
Also used : BeanTypeInfo(org.apache.cxf.aegis.type.basic.BeanTypeInfo) AegisType(org.apache.cxf.aegis.type.AegisType) BeanType(org.apache.cxf.aegis.type.basic.BeanType) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 49 with AegisType

use of org.apache.cxf.aegis.type.AegisType in project cxf by apache.

the class StandaloneReadTest method testCollectionReadNoXsiType.

@Test
public void testCollectionReadNoXsiType() throws Exception {
    java.lang.reflect.Type listStringType = ListStringInterface.class.getMethods()[0].getGenericReturnType();
    context.setRootClasses(Collections.singleton(listStringType));
    context.initialize();
    XMLStreamReader streamReader = StaxUtils.createXMLStreamReader(getClass().getResourceAsStream("topLevelList.xml"));
    AegisReader<XMLStreamReader> reader = context.createXMLStreamReader();
    // until I fix type mapping to use java.lang.reflect.Type instead of
    // Class, I need to do the following
    QName magicTypeQName = new QName("urn:org.apache.cxf.aegis.types", "ArrayOfString");
    AegisType aegisRegisteredType = context.getTypeMapping().getType(magicTypeQName);
    Object something = reader.read(streamReader, aegisRegisteredType);
    List<String> correctAnswer = Arrays.asList("cat", "dog", "hailstorm");
    assertEquals(correctAnswer, something);
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) AegisType(org.apache.cxf.aegis.type.AegisType) QName(javax.xml.namespace.QName) Test(org.junit.Test)

Example 50 with AegisType

use of org.apache.cxf.aegis.type.AegisType in project cxf by apache.

the class CollectionTest method testType.

@Test
public void testType() throws Exception {
    Method m = CollectionService.class.getMethod("getStrings", new Class[0]);
    AegisType type = creator.createType(m, -1);
    tm.register(type);
    assertTrue(type instanceof CollectionType);
    CollectionType colType = (CollectionType) type;
    QName componentName = colType.getSchemaType();
    assertEquals("ArrayOfString", componentName.getLocalPart());
    assertEquals("ArrayOfString", componentName.getLocalPart());
    type = colType.getComponentType();
    assertNotNull(type);
    assertTrue(type.getTypeClass().isAssignableFrom(String.class));
}
Also used : AegisType(org.apache.cxf.aegis.type.AegisType) QName(javax.xml.namespace.QName) CollectionType(org.apache.cxf.aegis.type.collection.CollectionType) Method(java.lang.reflect.Method) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Aggregations

AegisType (org.apache.cxf.aegis.type.AegisType)97 QName (javax.xml.namespace.QName)43 Test (org.junit.Test)40 AbstractAegisTest (org.apache.cxf.aegis.AbstractAegisTest)35 DatabindingException (org.apache.cxf.aegis.DatabindingException)18 AegisContext (org.apache.cxf.aegis.AegisContext)16 TypeMapping (org.apache.cxf.aegis.type.TypeMapping)11 Element (org.w3c.dom.Element)11 Context (org.apache.cxf.aegis.Context)10 BeanType (org.apache.cxf.aegis.type.basic.BeanType)10 Method (java.lang.reflect.Method)9 MessageReader (org.apache.cxf.aegis.xml.MessageReader)9 TypeCreationOptions (org.apache.cxf.aegis.type.TypeCreationOptions)8 BeanTypeInfo (org.apache.cxf.aegis.type.basic.BeanTypeInfo)8 CollectionType (org.apache.cxf.aegis.type.collection.CollectionType)8 HashSet (java.util.HashSet)7 MapType (org.apache.cxf.aegis.type.collection.MapType)7 MessageWriter (org.apache.cxf.aegis.xml.MessageWriter)7 ElementReader (org.apache.cxf.aegis.xml.stax.ElementReader)7 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)5