1 19 20 package org.netbeans.modules.j2ee.earproject; 21 22 import java.io.File ; 23 import org.netbeans.api.project.ProjectManager; 24 import org.netbeans.junit.NbTestCase; 25 import org.netbeans.modules.j2ee.api.ejbjar.Ear; 26 import org.netbeans.modules.j2ee.dd.api.application.Application; 27 import org.netbeans.modules.j2ee.dd.api.application.DDProvider; 28 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule; 29 import org.netbeans.modules.j2ee.earproject.test.TestUtil; 30 import org.netbeans.modules.j2ee.earproject.ui.wizards.NewEarProjectWizardIteratorTest; 31 import org.netbeans.modules.j2ee.ejbjarproject.EjbJarProject; 32 import org.openide.filesystems.FileObject; 33 import org.openide.filesystems.FileUtil; 34 35 38 public class ProjectEarTest extends NbTestCase { 39 40 private String serverID; 41 42 public ProjectEarTest(String testName) { 43 super(testName); 44 } 45 46 protected void setUp() throws Exception { 47 super.setUp(); 48 TestUtil.makeScratchDir(this); 49 serverID = TestUtil.registerSunAppServer(this); 50 } 51 52 public void testModuleAddition() throws Exception { 53 File earDirF = new File (getWorkDir(), "testEA"); 55 String name = "Test EnterpriseApplication"; 56 String j2eeLevel = J2eeModule.JAVA_EE_5; 57 String ejbName = "testEA-ejb"; 58 NewEarProjectWizardIteratorTest.generateEARProject(earDirF, name, j2eeLevel, 59 serverID, null, ejbName, null, null, null, null); 60 FileObject earDirFO = FileUtil.toFileObject(earDirF); 61 FileObject ejbProjectFO = earDirFO.getFileObject("testEA-ejb"); 62 assertNotNull(ejbProjectFO); 63 64 File earDirAnotherF = new File (getWorkDir(), "testEA-another"); 65 NewEarProjectWizardIteratorTest.generateEARProject(earDirAnotherF, name, j2eeLevel, 66 serverID, null, null, null, null, null, null); 67 FileObject earDirAnotherFO = FileUtil.toFileObject(earDirAnotherF); 68 EjbJarProject createdEjbJarProject = (EjbJarProject) ProjectManager.getDefault().findProject(ejbProjectFO); 69 assertNotNull("ejb project found", createdEjbJarProject); 70 Ear ear = Ear.getEar(earDirAnotherFO); 71 assertNotNull("have Ear instance", ear); 72 if (ear != null) { 73 ear.addEjbJarModule(createdEjbJarProject.getAPIEjbJar()); 74 } 75 76 EarProject earProject = (EarProject) ProjectManager.getDefault().findProject(earDirAnotherFO); 77 Application app = DDProvider.getDefault().getDDRoot( 78 earProject.getAppModule().getDeploymentDescriptor()); 79 assertSame("ejb added modules", 1, app.getModule().length); 80 81 } 82 83 } 84 | Popular Tags |