KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > jmi > javamodel > regenerator > Main


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 /*
20  * Main.java
21  *
22  * Created on 04 December 2003, 18:23
23  */

24
25 package org.netbeans.jmi.javamodel.regenerator;
26
27 import java.beans.PropertyVetoException JavaDoc;
28 import java.io.File JavaDoc;
29 import java.io.IOException JavaDoc;
30 import junit.textui.TestRunner;
31 import org.netbeans.jmi.javamodel.codegen.Utility;
32 import org.netbeans.jmi.javamodel.codegen.Utility;
33 import org.netbeans.junit.NbTestCase;
34 import org.netbeans.junit.NbTestSuite;
35 import org.openide.filesystems.FileSystem;
36 import org.openide.filesystems.LocalFileSystem;
37
38 /**
39  *
40  * @author Jan Becicka
41  */

42 public class Main extends NbTestCase {
43     
44     /** Need to be defined because of JUnit */
45     public Main(String JavaDoc name) {
46         super(name);
47         
48     }
49     
50     /**
51      * @param args the command line arguments
52      */

53     public static void main(String JavaDoc[] args) {
54         TestRunner.run(suite());
55     }
56     
57     public static NbTestSuite suite() {
58         NbTestSuite suite = new NbTestSuite();
59         suite.addTest(new Main("testRegenerateFileSystem"));
60         return suite;
61     }
62     
63     /**
64      * test can be customized using system properties:
65      * org.netbeans.javacore.fsname: name of filesystem to duplicate
66      * e.g. -Dorg.netbeans.javacore.fsname=/tmp/myfs
67      *
68      * org.netbeans.javacore.useJavadoc: true = copy javadoc using model elements
69      * false = copy javadoc textually
70      * e.g. -Dorg.netbeans.javacore.useJavadoc=false
71      *
72      * org.netbeans.javacore.useBody: true = copy bodies using model elements
73      * false = copy bodies textually
74      * e.g. -Dorg.netbeans.javacore.useBody=true
75      *
76      * org.netbeans.javacore.useInitialValue true = copy initial values using model elements
77      * false = copy initial values textually
78      * e.g. -Dorg.netbeans.javacore.useInitialValue=true
79      */

80     public void testRegenerateFileSystem () {
81         String JavaDoc fsName = System.getProperty("org.netbeans.javacore.fsname");
82         FileSystem fs = null;
83         if (fsName == null) {
84             fs = Utility.findFileSystem("sampledir");
85         } else {
86             try {
87                 fs = new LocalFileSystem();
88                 ((LocalFileSystem) fs).setRootDirectory(new File JavaDoc(fsName));
89             } catch (PropertyVetoException JavaDoc e) {
90                 fail(e.toString());
91             } catch (IOException JavaDoc e) {
92                 fail(e.toString());
93             }
94         }
95             
96         Regenerator regenerator = new Regenerator();
97         regenerator.setSourceFileSystem(fs);
98         regenerator.setTargetFileSystem(Utility.findFileSystem("testsrc"));
99         regenerator.regenerateAll();
100     }
101 }
102
Popular Tags