1 19 20 package org.netbeans.modules.j2ee.clientproject; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import org.netbeans.api.project.Project; 25 import org.netbeans.api.project.ProjectManager; 26 import org.netbeans.junit.NbTestCase; 27 import org.netbeans.modules.j2ee.clientproject.AppClientProject.ProjectOpenedHookImpl; 28 import org.netbeans.modules.j2ee.clientproject.api.AppClientProjectGenerator; 29 import org.netbeans.modules.j2ee.clientproject.test.TestUtil; 30 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule; 31 import org.netbeans.spi.project.ui.ProjectOpenedHook; 32 import org.openide.filesystems.FileObject; 33 import org.openide.filesystems.FileUtil; 34 import org.xml.sax.SAXException ; 35 36 39 public class AppClientProjectTest extends NbTestCase { 40 41 private String serverID; 42 43 public AppClientProjectTest(String testName) { 44 super(testName); 45 } 46 47 protected void setUp() throws Exception { 48 super.setUp(); 49 TestUtil.makeScratchDir(this); 50 serverID = TestUtil.registerSunAppServer(this); 51 } 52 53 public void testBrokenAppClientOpening_73710() throws Exception { 54 doTestBrokenAppClientOpening_73710(generateApplicationClient( 55 "TestCreateACProject_14", J2eeModule.J2EE_14)); 56 doTestBrokenAppClientOpening_73710(generateApplicationClient( 57 "TestCreateACProject_15", J2eeModule.JAVA_EE_5)); 58 } 59 60 private void doTestBrokenAppClientOpening_73710(final File prjDirF) throws IOException , IllegalArgumentException { 61 File dirCopy = TestUtil.copyFolder(getWorkDir(), prjDirF); 62 File ddF = new File (dirCopy, "src/conf/application-client.xml"); 63 assertTrue("has deployment descriptor", ddF.isFile()); 64 ddF.delete(); FileObject fo = FileUtil.toFileObject(dirCopy); 66 Project project = ProjectManager.getDefault().findProject(fo); 67 assertNotNull("project is found", project); 68 AppClientProjectTest.openProject((AppClientProject) project); 70 } 71 72 private File generateApplicationClient(String prjDir, String version) throws IOException , SAXException { 73 File prjDirF = new File (getWorkDir(), prjDir); 74 AppClientProjectGenerator.createProject(prjDirF, "test-project", 75 "test.MyMain", version, serverID); 76 return prjDirF; 77 } 78 79 83 public static void openProject(final Project p) { 84 ProjectOpenedHookImpl hook = (ProjectOpenedHookImpl) p.getLookup().lookup(ProjectOpenedHook.class); 85 assertNotNull("has an OpenedHook", hook); 86 hook.projectOpened(); } 88 89 } 90 | Popular Tags |