|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
TestXMLReplay.java | 0% | 0% | 0% | 0% |
|
1 |
package swingset;
|
|
2 |
|
|
3 |
import demo.SwingSet;
|
|
4 |
|
|
5 |
import junit.extensions.xml.XMLTestSuite;
|
|
6 |
import junit.extensions.jfcunit.xml.XMLRecorder;
|
|
7 |
import junit.framework.Test;
|
|
8 |
import junit.textui.TestRunner;
|
|
9 |
import java.io.InputStream;
|
|
10 |
import java.io.FileInputStream;
|
|
11 |
import java.io.IOException;
|
|
12 |
|
|
13 |
/**
|
|
14 |
* This class starts the XML Test scripts "saved.xml"
|
|
15 |
* It also sets the XMLRecorder.setReplay(true) which
|
|
16 |
* causes the Record statements to be ignored.
|
|
17 |
*
|
|
18 |
* @author <a href="mailto:kwilson227@users.sourceforge.net">Kevin Wilson</a>
|
|
19 |
* @author <a href="mailto:vraravam@thoughtworks.com">Vijay Aravamudhan : ThoughtWorks Inc.</a>
|
|
20 |
*/
|
|
21 |
public class TestXMLReplay extends XMLTestSuite { |
|
22 |
|
|
23 |
/** Document factory key. */
|
|
24 |
public static final String DOCUMENT_FACTORY = "javax.xml.parsers.DocumentBuilderFactory"; |
|
25 |
|
|
26 |
/**
|
|
27 |
* Construct a TestXMLReplay().
|
|
28 |
* Use testSwingSet.xml as the XML test definition.
|
|
29 |
*/
|
|
30 | 0 |
public TestXMLReplay() {
|
31 | 0 |
super("saved.xml", openFile("saved.xml")); |
32 | 0 |
XMLRecorder.setReplay(true);
|
33 | 0 |
SwingSet.main(new String[] {});
|
34 | 0 |
try {
|
35 | 0 |
Thread.currentThread().sleep(3000); |
36 |
} catch (Exception e) {
|
|
37 |
// Ignore
|
|
38 |
} |
|
39 |
} |
|
40 |
|
|
41 |
/**
|
|
42 |
* Open the file name given.
|
|
43 |
* @param fileName File name to be opened
|
|
44 |
* @return InputStrem to be processed.
|
|
45 |
*/
|
|
46 | 0 |
private static InputStream openFile(final String fileName) { |
47 | 0 |
try {
|
48 | 0 |
return new FileInputStream(fileName); |
49 |
} catch (IOException ioe) {
|
|
50 | 0 |
return null; |
51 |
} |
|
52 |
} |
|
53 |
|
|
54 |
/**
|
|
55 |
* Create a test suite for this object.
|
|
56 |
* @return Test Suite of tests to be executed.
|
|
57 |
*/
|
|
58 | 0 |
public static Test suite() { |
59 | 0 |
return new TestXMLReplay(); |
60 |
} |
|
61 |
|
|
62 |
/**
|
|
63 |
* Main method to run this class from the command line.
|
|
64 |
* Use the internal parse if available otherwise use the
|
|
65 |
* xerces parser.
|
|
66 |
*
|
|
67 |
* @param args Command line arguments.
|
|
68 |
*/
|
|
69 | 0 |
public static void main(final String[] args) { |
70 |
// Java 1.4 should already be configured for XML.
|
|
71 |
// Or if the user has configured the property use the
|
|
72 |
// Existing property. Otherwise we will assume, that
|
|
73 |
// the Xerces parser will be used.
|
|
74 | 0 |
if (System.getProperty(DOCUMENT_FACTORY) == null) { |
75 | 0 |
System.setProperty(DOCUMENT_FACTORY, |
76 |
"org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
|
|
77 |
} |
|
78 | 0 |
TestRunner.run((Test) TestXMLReplay.suite()); |
79 |
} |
|
80 |
} |
|
81 |
|
|