1 19 20 package org.netbeans.modules.j2ee.ejbfreeform; 21 22 import java.io.File ; 23 import org.netbeans.api.project.Project; 24 import org.netbeans.api.project.ProjectManager; 25 import org.netbeans.junit.*; 26 import org.netbeans.modules.ant.freeform.FreeformProject; 27 import org.netbeans.modules.java.platform.JavaPlatformProvider; 28 import org.openide.filesystems.FileObject; 29 import org.openide.filesystems.FileSystem; 30 import org.openide.filesystems.FileUtil; 31 import org.openide.filesystems.LocalFileSystem; 32 import org.openide.filesystems.MultiFileSystem; 33 import org.openide.filesystems.Repository; 34 import org.openide.filesystems.XMLFileSystem; 35 import org.openide.modules.ModuleInfo; 36 import org.openide.util.Lookup; 37 import org.openide.util.lookup.InstanceContent; 38 import org.openide.util.lookup.Lookups; 39 import org.openide.util.lookup.ProxyLookup; 40 41 45 public class TestBase extends NbTestCase { 46 47 static { 48 } 50 51 protected File egdir; 52 protected FileObject buildXml; 53 protected FreeformProject ejbFF; 54 protected FileObject ejbJarXml; 55 protected FileObject bean; 56 protected FileObject schema; 57 58 public TestBase(java.lang.String testName) { 59 super(testName); 60 } 61 62 protected void setUp() throws Exception { 63 super.setUp(); 64 Lookup.getDefault().lookup(ModuleInfo.class); 65 clearWorkDir(); 66 scratchF = getWorkDir(); 67 mkdir("system/J2EE/InstalledServers"); 68 mkdir("system/J2EE/DeploymentPlugins"); 69 System.setProperty("SYSTEMDIR", new File (scratchF, "system").getAbsolutePath()); 70 FileObject sfs = Repository.getDefault().getDefaultFileSystem().getRoot(); 71 assertNotNull("no default FS", sfs); 72 FileObject j2eeFolder = sfs.getFileObject("J2EE"); 73 assertNotNull("have J2EE", j2eeFolder); 74 } 75 76 protected void setUpProject() throws Exception { 77 egdir = FileUtil.normalizeFile(getDataDir()); 78 assertTrue("data dir " + egdir + " exists", egdir.exists()); 79 FileObject prjDir = FileUtil.toFileObject(egdir).getFileObject("test-app"); 80 assertNotNull("found projdir", prjDir); 81 Project _ejbFF = ProjectManager.getDefault().findProject(prjDir); 82 assertNotNull("have a project", _ejbFF); 83 EJBProjectGeneratorTest.validate(_ejbFF); 84 ejbFF = (FreeformProject)_ejbFF; 85 ejbJarXml = prjDir.getFileObject("conf/ejb-jar.xml"); 86 assertNotNull("found ejb-jar.xml", ejbJarXml); 87 bean = prjDir.getFileObject("src/beans/ent/CustomerLocal.java"); 88 assertNotNull("found CustomerLocal", bean); 89 schema = prjDir.getFileObject("resources/APP_test-app.dbschema"); 90 assertNotNull("found dbschema", schema); 91 buildXml = prjDir.getFileObject("build.xml"); 92 assertNotNull("found build.xml", buildXml); 93 } 94 95 protected boolean runInEQ() { 96 return true; 97 } 98 99 private File scratchF; 100 101 private void mkdir(String path) { 102 new File (scratchF, path.replace('/', File.separatorChar)).mkdirs(); 103 } 104 105 165 } 166 | Popular Tags |