Package org.apache.xmlbeans

Examples of org.apache.xmlbeans.XmlObject


    }

    public void testWeb22To24Transform1() throws Exception {
        File srcXml = new File(basedir, "src/test-data/j2ee_1_2dtd/web-1-22.xml");
        File expectedOutputXml = new File(basedir, "src/test-data/j2ee_1_2dtd/web-1-24.xml");
        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
        xmlObject = SchemaConversionUtils.convertToServletSchema(xmlObject);
        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
//        System.out.println(xmlObject.toString());
//        System.out.println(expected.toString());
        List problems = new ArrayList();
        boolean ok = compareXmlObjects(xmlObject, expected, problems);
        assertTrue("Differences: " + problems, ok);
View Full Code Here


        assertTrue("Differences: " + problems, ok2);
    }

    public void testWebRejectBad24() throws Exception {
        File srcXml = new File(basedir, "src/test-data/j2ee_1_4schema/web-1-24.xml");
        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
        try {
            xmlObject = SchemaConversionUtils.convertToServletSchema(xmlObject);
            fail("doc src/test-data/j2ee_1_4schema/web-1-24.xml is invalid, should not have validated");
        } catch (XmlException e) {
            //expected
View Full Code Here

        }
    }

    public void testParseWeb24() throws Exception {
        File srcXml = new File(basedir, "src/test-data/j2ee_1_4schema/web-2-24.xml");
        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
        xmlObject = SchemaConversionUtils.convertToServletSchema(xmlObject);
    }
View Full Code Here

    }

    public void testEJB21To21DoesNothing() throws Exception {
        File srcXml = new File(basedir, "src/test-data/j2ee_1_4schema/ejb-jar.xml");
        File expectedOutputXml = new File(basedir, "src/test-data/j2ee_1_4schema/ejb-jar.xml");
        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
        xmlObject = SchemaConversionUtils.convertToEJBSchema(xmlObject);
        XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
        List problems = new ArrayList();
        boolean ok = compareXmlObjects(xmlObject, expected, problems);
        assertTrue("Differences: " + problems, ok);
    }
View Full Code Here

    }

    public void testGeronimoNamingNamespaceChange() throws Exception {
        File srcXml = new File(basedir, "src/test-data/geronimo/ejb-naming-pre.xml");
        File expectedOutputXml = new File(basedir, "src/test-data/geronimo/ejb-naming-post.xml");
        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
        XmlCursor cursor = xmlObject.newCursor();
        try {
            SchemaConversionUtils.convertToGeronimoSubSchemas(cursor);
            //        System.out.println(xmlObject.toString());
            XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
            List problems = new ArrayList();
            boolean ok = compareXmlObjects(xmlObject, expected, problems);
            assertTrue("Differences: " + problems, ok);
            SchemaConversionUtils.convertToGeronimoSubSchemas(cursor);
            boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
View Full Code Here

    }
//
    public void testGetNestedObjectAsType() throws Exception {
        File srcXml = new File(basedir, "src/test-data/geronimo/ejb-naming-pre.xml");
//        File expectedOutputXml = new File(basedir, "src/test-data/geronimo/ejb-naming-post.xml");
        XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
        //this is not a usable type, we'll see what happens though
        xmlObject = SchemaConversionUtils.getNestedObjectAsType(xmlObject, "openejb-jar", EjbJarType.type);
//          System.out.println(xmlObject.toString());
    }
View Full Code Here

            convertToDescriptionGroup(cursor, moveable);
        } finally {
            cursor.dispose();
            moveable.dispose();
        }
        XmlObject result = xmlObject.changeType(ApplicationDocument.type);
        if (result != null) {
            validateDD(result);
            return (ApplicationDocument) result;
        }
        validateDD(xmlObject);
View Full Code Here

            convertToDescriptionGroup(cursor, moveable);
        } finally {
            cursor.dispose();
            moveable.dispose();
        }
        XmlObject result = xmlObject.changeType(ApplicationClientDocument.type);
        if (result != null) {
            validateDD(result);
            return (ApplicationClientDocument) result;
        }
        validateDD(xmlObject);
View Full Code Here

            }
        } finally {
            cursor.dispose();
        }
        XmlObject result = xmlObject.changeType(ConnectorDocument.type);
        if (result != null) {
            validateDD(result);
            return (ConnectorDocument) result;
        }
        validateDD(xmlObject);
View Full Code Here

        XmlCursor cursor = xmlObject.newCursor();
        XmlCursor moveable = xmlObject.newCursor();
        try {
            cursor.toFirstChild();
            if ("http://java.sun.com/xml/ns/j2ee".equals(cursor.getName().getNamespaceURI())) {
                XmlObject result = xmlObject.changeType(EjbJarDocument.type);
                validateDD(result);
                return (EjbJarDocument) result;
            }
            XmlDocumentProperties xmlDocumentProperties = cursor.documentProperties();
            String publicId = xmlDocumentProperties.getDoctypePublicId();
            String cmpVersion;
            if ("-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN".equals(publicId)) {
                cmpVersion = "1.x";
            } else if ("-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN".equals(publicId)) {
                cmpVersion = null;//2.x is the default "2.x";
            } else {
                throw new XmlException("Unrecognized document type: " + publicId);
            }
            String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd";
            String version = "2.1";
            convertToSchema(cursor, J2EE_NAMESPACE, schemaLocationURL, version);
            //play with message-driven
            cursor.toStartDoc();
            convertBeans(cursor, moveable, cmpVersion);
        } finally {
            cursor.dispose();
            moveable.dispose();
        }
        XmlObject result = xmlObject.changeType(EjbJarDocument.type);
        if (result != null) {
            validateDD(result);
            return (EjbJarDocument) result;
        }
        validateDD(xmlObject);
View Full Code Here

TOP

Related Classes of org.apache.xmlbeans.XmlObject

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.