1 19 20 package org.netbeans.modules.j2ee.earproject.ui.customizer; 21 22 import java.io.File ; 23 import java.util.HashSet ; 24 import java.util.List ; 25 import org.netbeans.api.project.Project; 26 import org.netbeans.api.project.ProjectManager; 27 import org.netbeans.junit.NbTestCase; 28 import org.netbeans.modules.j2ee.dd.api.application.Application; 29 import org.netbeans.modules.j2ee.dd.api.application.DDProvider; 30 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule; 31 import org.netbeans.modules.j2ee.earproject.EarProject; 32 import org.netbeans.modules.j2ee.earproject.EarProjectGenerator; 33 import org.netbeans.modules.j2ee.earproject.EarProjectTest; 34 import org.netbeans.modules.j2ee.earproject.EarProjectType; 35 import org.netbeans.modules.j2ee.earproject.test.TestUtil; 36 import org.netbeans.modules.j2ee.earproject.ui.wizards.NewEarProjectWizardIteratorTest; 37 import org.netbeans.spi.project.AuxiliaryConfiguration; 38 import org.netbeans.spi.project.support.ant.AntProjectHelper; 39 import org.netbeans.spi.project.support.ant.ReferenceHelper; 40 import org.openide.filesystems.FileObject; 41 import org.openide.filesystems.FileUtil; 42 43 46 public class EarProjectPropertiesTest extends NbTestCase { 47 48 private String serverID; 49 50 public EarProjectPropertiesTest(String testName) { 51 super(testName); 52 } 53 54 protected void setUp() throws Exception { 55 super.setUp(); 56 TestUtil.makeScratchDir(this); 57 serverID = TestUtil.registerSunAppServer(this); 58 } 59 60 public void testPropertiesWithoutDD() throws Exception { File proj = new File (getWorkDir(), "EARProject"); 62 AntProjectHelper aph = EarProjectGenerator.createProject(proj, 63 "test-project", J2eeModule.JAVA_EE_5, serverID, "1.5"); 64 FileObject prjDirFO = aph.getProjectDirectory(); 65 prjDirFO.getFileObject("src/conf/application.xml").delete(); 67 Project p = ProjectManager.getDefault().findProject(prjDirFO); 68 AuxiliaryConfiguration aux = aph.createAuxiliaryConfiguration(); 69 ReferenceHelper refHelper = new ReferenceHelper(aph, aux, aph.getStandardPropertyEvaluator()); 70 EarProjectProperties epp = new EarProjectProperties((EarProject) p, refHelper, new EarProjectType()); 71 assertNotNull("non-null application modules", epp.getApplicationModules()); 72 } 73 74 public void testPathInEARChanging() throws Exception { File earDirF = new File (getWorkDir(), "testEA"); 76 String name = "Test EnterpriseApplication"; 77 String j2eeLevel = J2eeModule.JAVA_EE_5; 78 String ejbName = "testEA-ejb"; 79 NewEarProjectWizardIteratorTest.generateEARProject(earDirF, name, j2eeLevel, 80 serverID, null, ejbName, null, null, null, null); 81 EarProject earProject = (EarProject) ProjectManager.getDefault().findProject(FileUtil.toFileObject(earDirF)); 82 Application app = DDProvider.getDefault().getDDRoot( 83 earProject.getAppModule().getDeploymentDescriptor()); 84 assertEquals("ejb path", "testEA-ejb.jar", app.getModule(0).getEjb()); 85 86 EarProjectProperties epp = earProject.getProjectProperties(); 88 List <VisualClassPathItem> vcpis = epp.getJarContentAdditional(); 89 vcpis.get(0).setPathInEAR("otherPath"); 90 epp.updateContentDependency( 91 new HashSet <VisualClassPathItem>(vcpis), 92 new HashSet <VisualClassPathItem>(vcpis)); 93 94 assertEquals("ejb path", "otherPath/testEA-ejb.jar", app.getModule(0).getEjb()); 95 } 96 97 public void testSetACPrivateProperties() throws Exception { File earDirF = new File (getWorkDir(), "testEA"); 99 String name = "Test EnterpriseApplication"; 100 String j2eeLevel = J2eeModule.JAVA_EE_5; 101 String acName = "testEA-ac"; 102 NewEarProjectWizardIteratorTest.generateEARProject(earDirF, name, j2eeLevel, 103 serverID, null, null, acName, null, null, null); 104 EarProject earProject = (EarProject) ProjectManager.getDefault().findProject(FileUtil.toFileObject(earDirF)); 105 earProject.getProjectDirectory().getFileObject(AntProjectHelper.PRIVATE_PROPERTIES_PATH).delete(); 106 EarProjectTest.openProject(earProject); 107 assertNotNull("private properties successfully regenerated", earProject.getAntProjectHelper().getProperties( 108 AntProjectHelper.PRIVATE_PROPERTIES_PATH).getProperty(EarProjectProperties.APPCLIENT_WA_COPY_CLIENT_JAR_FROM)); 109 } 110 } 111 | Popular Tags |