fulcrum.xml.soap12.Soap12XOMTest.java Source code

Java tutorial

Introduction

Here is the source code for fulcrum.xml.soap12.Soap12XOMTest.java

Source

/**
 * Copyright (c)2012, Rational Developers; Ryan McGuinness
 * All rights reserved
 * Site: http://www.rationaldevelopers.com/fulcrum-xml
 * License: http://www.rationaldevelopers.com/fulcrum-xml/license.txt
 * Read Me: http://www.rationaldevelopers.com/fulcrum-xml/readme.txt
 *.
 */
package fulcrum.xml.soap12;

import java.io.InputStream;

import nu.xom.Builder;
import nu.xom.Document;

import org.apache.commons.vfs2.FileContent;
import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystemManager;
import org.apache.commons.vfs2.VFS;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 
 * @author Rational Developers
 * @author Ryan McGuinness
 *
 */
public class Soap12XOMTest {
    private static final Logger LOGGER = LoggerFactory.getLogger(Soap12Test.class);
    public static final String SIMPLE = "res:fulcrum/xml/input-medium.xml";

    @Test
    public void testXOM() {
        Document doc = null;
        Builder parser = null;
        try {
            FileSystemManager fsManager = VFS.getManager();
            FileObject fileObj = fsManager.resolveFile(SIMPLE);
            if (fileObj != null && fileObj.exists() && fileObj.isReadable()) {

                FileContent content = fileObj.getContent();
                InputStream is = content.getInputStream();
                LOGGER.info("STARTING PARSE:");
                parser = new Builder();
                doc = parser.build(is);
                LOGGER.info("ENDING PARSE");
                System.out.println(doc.toXML());
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            parser = null;
        }
    }
}