< prev index next >

test/javax/xml/jaxp/unittest/stream/XMLStreamWriterTest/DomUtilTest.java

Print this page




  24 package stream.XMLStreamWriterTest;
  25 
  26 import java.io.ByteArrayOutputStream;
  27 import java.io.File;
  28 import java.io.FileInputStream;
  29 import java.io.IOException;
  30 import java.io.InputStream;
  31 import java.io.PrintStream;
  32 
  33 import javax.xml.parsers.DocumentBuilder;
  34 import javax.xml.parsers.DocumentBuilderFactory;
  35 import javax.xml.parsers.ParserConfigurationException;
  36 import javax.xml.stream.XMLOutputFactory;
  37 import javax.xml.stream.XMLStreamWriter;
  38 import javax.xml.transform.Result;
  39 import javax.xml.transform.Transformer;
  40 import javax.xml.transform.TransformerFactory;
  41 import javax.xml.transform.dom.DOMSource;
  42 import javax.xml.transform.stream.StreamResult;
  43 

  44 import org.testng.annotations.Test;
  45 import org.w3c.dom.Element;
  46 import org.w3c.dom.Node;
  47 import org.xml.sax.SAXException;
  48 
  49 /*
  50  * @summary Test XMLStreamWriter writes a soap message.
  51  */

  52 public class DomUtilTest {
  53 
  54     private XMLOutputFactory staxOut;
  55     final File folder = new File(System.getProperty("tempdir") + "/classes/soapmessages");
  56     private static final String INPUT_FILE1 = "message_12.xml";
  57 
  58     public void setup() {
  59         this.staxOut = XMLOutputFactory.newInstance();
  60         staxOut.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true);
  61     }
  62 
  63     @Test
  64     public void testSOAPEnvelope1() throws Exception {
  65         setup();
  66 
  67         File f = new File(this.getClass().getResource(INPUT_FILE1).getFile());
  68         System.out.println("***********" + f.getName() + "***********");
  69         DOMSource src = makeDomSource(f);
  70         Node node = src.getNode();
  71         XMLStreamWriter writer = staxOut.createXMLStreamWriter(new PrintStream(System.out));
  72         DOMUtil.serializeNode((Element) node.getFirstChild(), writer);
  73         writer.close();
  74         assert (true);
  75         System.out.println("*****************************************");




  24 package stream.XMLStreamWriterTest;
  25 
  26 import java.io.ByteArrayOutputStream;
  27 import java.io.File;
  28 import java.io.FileInputStream;
  29 import java.io.IOException;
  30 import java.io.InputStream;
  31 import java.io.PrintStream;
  32 
  33 import javax.xml.parsers.DocumentBuilder;
  34 import javax.xml.parsers.DocumentBuilderFactory;
  35 import javax.xml.parsers.ParserConfigurationException;
  36 import javax.xml.stream.XMLOutputFactory;
  37 import javax.xml.stream.XMLStreamWriter;
  38 import javax.xml.transform.Result;
  39 import javax.xml.transform.Transformer;
  40 import javax.xml.transform.TransformerFactory;
  41 import javax.xml.transform.dom.DOMSource;
  42 import javax.xml.transform.stream.StreamResult;
  43 
  44 import org.testng.annotations.Listeners;
  45 import org.testng.annotations.Test;
  46 import org.w3c.dom.Element;
  47 import org.w3c.dom.Node;
  48 import org.xml.sax.SAXException;
  49 
  50 /*
  51  * @summary Test XMLStreamWriter writes a soap message.
  52  */
  53 @Listeners({jaxp.library.FilePolicy.class})
  54 public class DomUtilTest {
  55 
  56     private XMLOutputFactory staxOut;

  57     private static final String INPUT_FILE1 = "message_12.xml";
  58 
  59     public void setup() {
  60         this.staxOut = XMLOutputFactory.newInstance();
  61         staxOut.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true);
  62     }
  63 
  64     @Test
  65     public void testSOAPEnvelope1() throws Exception {
  66         setup();
  67 
  68         File f = new File(this.getClass().getResource(INPUT_FILE1).getFile());
  69         System.out.println("***********" + f.getName() + "***********");
  70         DOMSource src = makeDomSource(f);
  71         Node node = src.getNode();
  72         XMLStreamWriter writer = staxOut.createXMLStreamWriter(new PrintStream(System.out));
  73         DOMUtil.serializeNode((Element) node.getFirstChild(), writer);
  74         writer.close();
  75         assert (true);
  76         System.out.println("*****************************************");


< prev index next >