Package org.apache.cxf.aegis

Examples of org.apache.cxf.aegis.Context


        type.setTypeMapping(mapping);
        type.setSchemaType(new QName("urn:Bean", "bean"));

        ElementReader reader = new ElementReader(getResourceAsStream("bean3.xml"));

        SimpleBean bean = (SimpleBean)type.readObject(reader, new Context());
        assertEquals("howdy", bean.getHowdy());
        assertNull(bean.getBleh());

        reader.getXMLStreamReader().close();

        // Test writing
        Element element = new Element("root", "b", "urn:Bean");
        new Document(element);
        type.writeObject(bean, new JDOMWriter(element), new Context());

        assertInvalid("/b:root/b:bleh", element);
        assertValid("/b:root/b:howdycustom[text()='howdy']", element);
    }
View Full Code Here


        type.setTypeMapping(mapping);
        type.setSchemaType(new QName("urn:Bean", "bean"));

        ElementReader reader = new ElementReader(getResourceAsStream("bean4.xml"));

        SimpleBean bean = (SimpleBean)type.readObject(reader, new Context());
        assertEquals("bleh", bean.getBleh());
        assertEquals("howdy", bean.getHowdy());

        reader.getXMLStreamReader().close();

        // Test writing
        Element element = new Element("root", "b", "urn:Bean");
        new Document(element);
        type.writeObject(bean, new JDOMWriter(element), new Context());

        assertValid("/b:root[@b:bleh='bleh']", element);
        assertValid("/b:root[@b:howdy='howdy']", element);

        Element types = new Element("types", "xsd", XmlConstants.XSD);
View Full Code Here

        type.setTypeMapping(mapping);
        type.setSchemaType(new QName("urn:Bean", "bean"));

        ElementReader reader = new ElementReader(getResourceAsStream("bean8.xml"));

        SimpleBean bean = (SimpleBean)type.readObject(reader, new Context());
        assertEquals("bleh", bean.getBleh());
        assertEquals("howdy", bean.getHowdy());

        reader.getXMLStreamReader().close();

        // Test writing

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ElementWriter writer = new ElementWriter(bos, "root", "urn:Bean");
        type.writeObject(bean, writer, new Context());
        writer.close();
        writer.flush();

        bos.close();
       
View Full Code Here

        SimpleBean bean = new SimpleBean();

        // Test writing
        Element element = new Element("root", "b", "urn:Bean");
        new Document(element);
        type.writeObject(bean, new JDOMWriter(element), new Context());

        assertInvalid("/b:root[@b:howdy]", element);
        assertValid("/b:root/b:bleh[@xsi:nil='true']", element);

        Element types = new Element("types", "xsd", XmlConstants.XSD);
View Full Code Here

        DateBean bean = new DateBean();

        // Test writing
        Element element = new Element("root", "b", "urn:Bean");
        new Document(element);
        type.writeObject(bean, new JDOMWriter(element), new Context());

        // Make sure the date doesn't have an element. Its non nillable so it
        // just
        // shouldn't be there.
        assertInvalid("/b:root/b:date", element);
View Full Code Here

        ExtendedBean bean = new ExtendedBean();
        bean.setHowdy("howdy");

        Element element = new Element("root", "b", "urn:Bean");
        new Document(element);
        type.writeObject(bean, new JDOMWriter(element), new Context());

        assertValid("/b:root/b:howdy[text()='howdy']", element);
    }
View Full Code Here

        ByteBean bean = new ByteBean();

        // Test writing
        Element element = new Element("root", "b", "urn:Bean");
        new Document(element);
        type.writeObject(bean, new JDOMWriter(element), new Context());

        // Make sure the date doesn't have an element. Its non nillable so it
        // just
        // shouldn't be there.

        addNamespace("xsi", XmlConstants.XSI_NS);
        assertValid("/b:root/b:data[@xsi:nil='true']", element);

        bean = (ByteBean)type.readObject(new JDOMReader(element), new Context());
        assertNotNull(bean);
        assertNull(bean.getData());
    }
View Full Code Here

        MapNamespaceContext namespaces = new MapNamespaceContext();
        for (Map.Entry<String, String> entry : getNamespaces().entrySet()) {
            namespaces.addNamespace(entry.getKey(), entry.getValue());
        }
        ElementWriter rootWriter = getElementWriter(element, namespaces);
        Context context = getContext();

        // get Type based on the object instance
        assertNotNull("type is null", type);

        // write the ref
View Full Code Here

    public void verifyInvalid(String resourceName, Class<?> expectedType) throws XMLStreamException {
        Type type = mapping.getType(expectedType);
        assertNotNull("type is null", type);

        Context context = getContext();

        ElementReader reader = new ElementReader(getClass().getResourceAsStream(resourceName));
        try {
            type.readObject(reader, context);
            fail("expected DatabindingException");
View Full Code Here

        mapping.register(arrayOfAny);
    }

    @Test
    public void testSimpleArray() throws Exception {
        Context context = getContext();

        // xsd:int[2]
        ElementReader reader = new ElementReader(getClass().getResourceAsStream("arraySimple.xml"));
        int[] numbers = (int[]) createArrayType(int[].class).readObject(reader, context);
        reader.getXMLStreamReader().close();
View Full Code Here

TOP

Related Classes of org.apache.cxf.aegis.Context

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.