KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > design > schema2java > JavaGeneratorTest


1 /*
2  * JavaGeneratorTest.java
3  *
4  * Created on March 6, 2007, 4:10 PM
5  *
6  * To change this template, choose Tools | Template Manager
7  * and open the template in the editor.
8  */

9
10 package org.netbeans.modules.websvc.design.schema2java;
11
12 import java.io.File JavaDoc;
13 import java.util.List JavaDoc;
14 import org.netbeans.junit.NbTestCase;
15
16 /**
17  *
18  * @author mkuchtiak
19  */

20 public class JavaGeneratorTest extends NbTestCase {
21     
22     static File JavaDoc workingDirectory;
23     public JavaGeneratorTest(String JavaDoc testName) {
24         super(testName);
25     }
26
27     protected void setUp() throws Exception JavaDoc {
28         clearWorkDir();
29         workingDirectory = getWorkDir();
30     }
31
32     protected void tearDown() throws Exception JavaDoc {
33     }
34     
35     
36     /** generates java artifacts for selected schema element
37      */

38     public void testGenerateJava () {
39         JavaGenerator generator = new JavaGenerator();
40         JavaGenerator.XJCResult result = generator.generateJavaArtifacts(getFile("Book.xsd"),"Collection", workingDirectory ,"book");
41         File JavaDoc bookPackage = new File JavaDoc(workingDirectory.getAbsolutePath()+File.separator+"book");
42         assertTrue("package not created",bookPackage.exists());
43         assertNotNull(result.getPrimaryFile());
44         assertTrue("Primary File "+result.getPrimaryFile()+" not created",result.getPrimaryFile().exists());
45         List JavaDoc<File JavaDoc> secondaryFiles = result.getSecondaryFiles();
46         assertNotNull(secondaryFiles);
47         for (File JavaDoc file:secondaryFiles) {
48             assertTrue("SecondaryFile "+file+" not created",file.exists());
49         }
50     }
51     
52     private File JavaDoc getFile(String JavaDoc file) {
53         return new File JavaDoc(getDataDir(),file);
54     }
55     
56 }
57
Popular Tags