KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > om > CompareOMWithDOMTest


1 /*
2  * Copyright 2004,2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.axis2.om;
17
18 import org.apache.axis2.soap.SOAPEnvelope;
19 import org.w3c.dom.Document JavaDoc;
20
21 import javax.xml.parsers.DocumentBuilder JavaDoc;
22 import javax.xml.parsers.DocumentBuilderFactory JavaDoc;
23 import java.io.File JavaDoc;
24
25 /**
26  * @version $Rev: $ $Date: $
27  */

28 public class CompareOMWithDOMTest extends AbstractTestCase {
29     /**
30      * @param testName
31      */

32     public CompareOMWithDOMTest(String JavaDoc testName) {
33         super(testName);
34     }
35
36     public void testAllMessagesInSOAP() throws OMException, Exception JavaDoc {
37         File JavaDoc dir = new File JavaDoc(testResourceDir, "soap");
38         File JavaDoc[] files = dir.listFiles();
39         if (files != null) {
40             for (int i = 0; i < files.length; i++) {
41                 if (files[i].isFile() && files[i].getName().endsWith(".xml")) {
42                     System.out.println("files = " + files[i].getAbsolutePath());
43                     SOAPEnvelope soapEnvelope = (SOAPEnvelope) OMTestUtils.getOMBuilder(files[i]).getDocumentElement();
44                     DocumentBuilderFactory JavaDoc dbf = DocumentBuilderFactory.newInstance();
45                     dbf.setNamespaceAware(true);
46                     DocumentBuilder JavaDoc builder = dbf.newDocumentBuilder();
47                     Document JavaDoc doc = builder.parse(files[i].getAbsolutePath());
48
49 // XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out) ;
50
// soapEnvelope.serializeWithCache(writer);
51
// writer.flush();
52
OMTestUtils.compare(doc.getDocumentElement(), soapEnvelope);
53                 }
54             }
55
56         }
57     }
58 }
59
Popular Tags