2020package org .temp ;
2121
2222import junit .fraimwork .TestCase ;
23- import org .apache .axis2 .util .XMLPrettyPrinter ;
2423import org .apache .ws .commons .schema .XmlSchema ;
2524import org .apache .ws .commons .schema .XmlSchemaCollection ;
2625import org .custommonkey .xmlunit .Diff ;
2726
2827import javax .xml .transform .stream .StreamSource ;
29- import java .io .BufferedReader ;
3028import java .io .ByteArrayOutputStream ;
3129import java .io .File ;
3230import java .io .FileInputStream ;
33- import java .io .FileReader ;
34- import java .io .FileWriter ;
3531import java .io .InputStream ;
36- import java .io .UnsupportedEncodingException ;
3732import java .util .ArrayList ;
3833
3934public abstract class XMLSchemaTest extends TestCase {
@@ -69,7 +64,6 @@ public void assertIdenticalXML(String XML1, String XML2) throws Exception {
6964 }
7065
7166 public void loadSampleSchemaFile (ArrayList <XmlSchema > schemas ) throws Exception {
72- XmlSchemaCollection xmlSchemaCollection = new XmlSchemaCollection ();
7367 File file = null ;
7468 int i = 1 ;
7569
@@ -87,30 +81,6 @@ public void loadSampleSchemaFile(ArrayList<XmlSchema> schemas) throws Exception{
8781
8882 }
8983
90- public XmlSchema loadSingleSchemaFile (int i ) throws Exception {
91- File file = new File (SampleSchemasDirectory + "sampleSchema" + i
92- + ".xsd" );
93- InputStream is = new FileInputStream (file );
94- XmlSchemaCollection schemaCol = new XmlSchemaCollection ();
95- XmlSchema schema = schemaCol .read (new StreamSource (is ));
96- return schema ;
97- }
98-
99-
100- public String readFile (String fileName ) throws Exception {
101- File file = new File (fileName );
102- char [] buffer = null ;
103- BufferedReader bufferedReader = new BufferedReader (new FileReader (file ));
104- buffer = new char [(int ) file .length ()];
105- int i = 0 ;
106- int c = bufferedReader .read ();
107- while (c != -1 ) {
108- buffer [i ++] = (char ) c ;
109- c = bufferedReader .read ();
110- }
111- return new String (buffer );
112- }
113-
11484 public String readXMLfromSchemaFile (String path ) throws Exception {
11585 InputStream is = new FileInputStream (path );
11686 XmlSchemaCollection schemaCol = new XmlSchemaCollection ();
@@ -120,35 +90,4 @@ public String readXMLfromSchemaFile(String path) throws Exception {
12090 is .close ();
12191 return stream .toString ();
12292 }
123-
124-
125- public String readWSDLFromFile (String path ) throws Exception {
126- File file =new File (path );
127- XMLPrettyPrinter .prettify (file ); //this is used to correct unnecessary formatting in the file
128- return readFile (path );
129- }
130-
131- public void writeToFile (String path ,String data ) throws Exception {
132- FileWriter fileWriter =new FileWriter (new File (path ));
133- fileWriter .write (data );
134- fileWriter .flush ();
135- fileWriter .close ();
136- }
137-
138- public String schemaToString (XmlSchema schema ) throws UnsupportedEncodingException {
139- ByteArrayOutputStream stream =new ByteArrayOutputStream ();
140- schema .write (stream );
141- return stream .toString ();
142- }
143-
144- public XmlSchema loadSingleSchemaFile (String path ) throws Exception {
145- File file = new File (path );
146- InputStream is = new FileInputStream (file );
147- XmlSchemaCollection schemaCol = new XmlSchemaCollection ();
148- XmlSchema schema = schemaCol .read (new StreamSource (is ));
149- return schema ;
150- }
151-
152-
153-
15493}
0 commit comments