KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > japex > ConfigFileLoader


1 /*
2  * Japex ver. 0.1 software ("Software")
3  *
4  * Copyright, 2004-2005 Sun Microsystems, Inc. All Rights Reserved.
5  *
6  * This Software is distributed under the following terms:
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, is permitted provided that the following conditions are met:
10  *
11  * Redistributions of source code must retain the above copyright notice,
12  * this list of conditions and the following disclaimer.
13  *
14  * Redistribution in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the
16  * documentation and/or other materials provided with the distribution.
17  *
18  * Neither the name of Sun Microsystems, Inc., 'Java', 'Java'-based names,
19  * nor the names of contributors may be used to endorse or promote products
20  * derived from this Software without specific prior written permission.
21  *
22  * The Software is provided "AS IS," without a warranty of any kind. ALL
23  * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
24  * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25  * PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS
26  * SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE
27  * AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE
28  * SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE
29  * LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
30  * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED
31  * AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
32  * INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGES.
34  *
35  * You acknowledge that the Software is not designed, licensed or intended
36  * for use in the design, construction, operation or maintenance of any
37  * nuclear facility.
38  */

39
40 package com.sun.japex;
41
42 import java.io.*;
43 import java.util.ArrayList JavaDoc;
44 import java.util.Properties JavaDoc;
45 import javax.xml.bind.*;
46
47 public class ConfigFileLoader {
48     
49     TestSuite _testSuite;
50     
51     public ConfigFileLoader(String JavaDoc fileName) throws ConfigFileException {
52         try {
53             JAXBContext ctx = JAXBContext.newInstance("com.sun.japex.testsuite");
54             Unmarshaller u = ctx.createUnmarshaller();
55             
56             // Unmarshall config file into JAXB object
57
com.sun.japex.testsuite.TestSuite testsuite =
58                 (com.sun.japex.testsuite.TestSuite) u.unmarshal(
59                 new BufferedInputStream(new FileInputStream(fileName)));
60             
61             // Map JAXB object model to internal object model
62
_testSuite = new TestSuite(testsuite);
63         }
64         catch (Exception JavaDoc e) {
65             throw new RuntimeException JavaDoc(e);
66         }
67     }
68     
69     public TestSuite getTestSuite() {
70         return _testSuite;
71     }
72     
73 }
74
Popular Tags