KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > retriever > catalog > test > ModelSourceTest


1 /*
2  * ModelSourceTest.java
3  * JUnit based test
4  *
5  * Created on January 22, 2007, 6:38 PM
6  */

7
8 package org.netbeans.modules.xml.retriever.catalog.test;
9
10 import java.io.File JavaDoc;
11 import java.io.IOException JavaDoc;
12 import junit.framework.*;
13 import org.netbeans.modules.xml.xam.ModelSource;
14 import org.netbeans.modules.xml.xam.locator.CatalogModelException;
15 import org.openide.filesystems.FileObject;
16 import org.openide.filesystems.FileUtil;
17
18 /**
19  *
20  * @author girix
21  */

22 public class ModelSourceTest extends TestCase {
23     
24     public ModelSourceTest(String JavaDoc testName) {
25         super(testName);
26     }
27     
28     protected void setUp() throws Exception JavaDoc {
29     }
30     
31     protected void tearDown() throws Exception JavaDoc {
32     }
33     
34     public void testModelSource(){
35         
36                 /*
37                  * Step1: Copy
38                  * <nb_src>/xml/retriever/test/unit/src/org/netbeans/modules/xml/retriever/catalog/test/TestCatalogModel.java
39                  * to your unit test area.
40                  */

41         
42         
43         
44         
45         
46         
47         
48         
49         
50         
51         /*
52          *Step 2: IMPORTANT NOTE: also make sure that all the required jars are actually set in the unit test class path.
53          * This is done by placing or appending to the property (for more accurate list, copy and use from:
54          <nb_src>/xml/retriever/nbproject/project.properties)
55          
56          test.unit.cp.extra=\
57             ${netbeans.dest.dir}/ide7/modules/org-netbeans-modules-xml-retriever.jar:\
58             ${netbeans.dest.dir}/ide7/modules/org-netbeans-modules-xml-xdm.jar:\
59             ${netbeans.dest.dir}/ide7/modules/org-netbeans-modules-xml-xam.jar:\
60             ${netbeans.dest.dir}/ide7/modules/org-apache-xml-resolver.jar:\
61             ${netbeans.dest.dir}/ide7/modules/org-netbeans-modules-editor.jar:\
62             ${netbeans.dest.dir}/platform6/lib/org-openide-modules.jar:\
63             ${netbeans.dest.dir}/ide7/modules/org-netbeans-modules-editor-util.jar:\
64             ${netbeans.dest.dir}/ide7/modules/org-netbeans-modules-xml-text.jar:\
65             ${netbeans.dest.dir}/ide7/modules/org-netbeans-modules-xml-core.jar:\
66             ${netbeans.dest.dir}/ide7/modules/org-netbeans-modules-editor-lib.jar:\
67             ${netbeans.dest.dir}/ide7/modules/org-netbeans-modules-projectapi.jar:\
68             ${netbeans.dest.dir}/platform6/modules/org-netbeans-modules-masterfs.jar:\
69             ${netbeans.dest.dir}/platform6/modules/org-openide-windows.jar:\
70             ${netbeans.dest.dir}/platform6/modules/org-openide-dialogs.jar:\
71             ${netbeans.dest.dir}/platform6/modules/org-openide-awt.jar:\
72             ${netbeans.dest.dir}/platform6/modules/org-openide-options.jar:\
73             ${netbeans.dest.dir}/platform6/modules/org-openide-loaders.jar:\
74             ${netbeans.dest.dir}/platform6/core/org-openide-filesystems.jar:\
75             ${netbeans.dest.dir}/platform6/modules/org-openide-nodes.jar:\
76             ${netbeans.dest.dir}/platform6/modules/org-openide-text.jar:\
77             ${netbeans.dest.dir}/platform6/lib/org-openide-util.jar
78          */

79         
80         
81         //To create a model source use this code
82

83         //ModelSource ms = TestCatalogModel.getDefault().createTestModelSource(FileObject, editable);
84

85         /*Sample code*/
86         File JavaDoc file = null;
87         try {
88             file = File.createTempFile("modelsource", "deleteme");
89             file.deleteOnExit();
90         } catch (IOException JavaDoc ex) {
91             ex.printStackTrace();
92         }
93         //create ur own file object here
94
FileObject fo = FileUtil.toFileObject(FileUtil.normalizeFile(file));
95         ModelSource ms = null;
96         try {
97             ms = TestCatalogModel.getDefault().createTestModelSource(fo, true);
98         } catch (CatalogModelException ex) {
99             ex.printStackTrace();
100         }
101         
102         System.out.println(ms.getLookup().lookup(FileObject.class));
103         
104     }
105     
106 }
107
Popular Tags