1 19 20 package org.netbeans.modules.j2ee.ejbjarproject; 21 22 import java.io.File ; 23 import org.netbeans.api.project.Project; 24 import org.netbeans.api.project.ProjectManager; 25 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule; 26 import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider; 27 import org.netbeans.modules.j2ee.ejbjarproject.test.TestBase; 28 import org.netbeans.modules.j2ee.ejbjarproject.ui.customizer.EjbJarProjectProperties; 29 import org.netbeans.modules.j2ee.spi.ejbjar.EjbJarImplementation; 30 import org.netbeans.spi.project.support.ant.AntProjectHelper; 31 import org.openide.filesystems.FileObject; 32 import org.openide.filesystems.FileUtil; 33 34 38 public class EjbJarProviderTest extends TestBase { 39 40 private static final String EJBJAR_XML = "ejb-jar.xml"; 41 42 private Project project; 43 private AntProjectHelper helper; 44 45 public EjbJarProviderTest(String testName) { 46 super(testName); 47 } 48 49 52 public void testPathsAreReturned() throws Exception { 53 File f = new File (getDataDir().getAbsolutePath(), "projects/EJBModule1"); 54 project = ProjectManager.getDefault().findProject(FileUtil.toFileObject(f)); 55 helper = ((EjbJarProject)project).getAntProjectHelper(); 57 58 String metaInf = helper.getStandardPropertyEvaluator().getProperty("meta.inf"); 60 assertTrue(metaInf.endsWith("conf")); 61 FileObject metaInfFO =helper.resolveFileObject(metaInf); 62 assertNotNull(metaInfFO); 63 64 FileObject ejbJarXmlFO = metaInfFO.getFileObject(EJBJAR_XML); 66 assertNotNull(ejbJarXmlFO); 67 assertNotNull(metaInfFO.getFileObject("webservices.xml")); 68 69 71 J2eeModuleProvider provider = (J2eeModuleProvider)project.getLookup().lookup(J2eeModuleProvider.class); 72 assertEquals(ejbJarXmlFO, provider.findDeploymentConfigurationFile(EJBJAR_XML)); 73 assertEquals(FileUtil.toFile(metaInfFO.getFileObject(EJBJAR_XML)), provider.getDeploymentConfigurationFile(EJBJAR_XML)); 74 75 J2eeModule j2eeModule = (J2eeModule)project.getLookup().lookup(J2eeModule.class); 76 assertNotNull(j2eeModule.getDeploymentDescriptor(J2eeModule.EJBJAR_XML)); 77 assertNotNull(j2eeModule.getDeploymentDescriptor(J2eeModule.EJBSERVICES_XML)); 78 79 EjbJarImplementation ejbJar = (EjbJarImplementation)project.getLookup().lookup(EjbJarImplementation.class); 80 assertEquals(metaInfFO, ejbJar.getMetaInf()); 81 assertEquals(ejbJarXmlFO, ejbJar.getDeploymentDescriptor()); 82 } 83 84 88 public void testMetaInfBasedPathsAreNullWhenMetaInfIsNullIssue65888() throws Exception { 89 File f = new File (getDataDir().getAbsolutePath(), "projects/BrokenEJBModule1"); 90 project = ProjectManager.getDefault().findProject(FileUtil.toFileObject(f)); 91 helper = ((EjbJarProject)project).getAntProjectHelper(); 93 94 String metaInf = helper.getStandardPropertyEvaluator().getProperty("meta.inf"); 96 assertTrue(metaInf.endsWith("conf")); 97 assertNull(helper.resolveFileObject(metaInf)); 98 99 101 J2eeModuleProvider provider = (J2eeModuleProvider)project.getLookup().lookup(J2eeModuleProvider.class); 102 assertNull(provider.findDeploymentConfigurationFile(EJBJAR_XML)); 103 assertNotNull(provider.getDeploymentConfigurationFile(EJBJAR_XML)); 104 105 J2eeModule j2eeModule = (J2eeModule)project.getLookup().lookup(J2eeModule.class); 106 assertNull(j2eeModule.getDeploymentDescriptor(J2eeModule.EJBJAR_XML)); 107 assertNull(j2eeModule.getDeploymentDescriptor(J2eeModule.EJBSERVICES_XML)); 108 109 EjbJarImplementation ejbJar = (EjbJarImplementation)project.getLookup().lookup(EjbJarImplementation.class); 110 assertNull(ejbJar.getMetaInf()); 111 assertNull(ejbJar.getDeploymentDescriptor()); 112 } 113 114 public void testNeedConfigurationFolder() { 115 assertTrue("1.3 needs configuration folder", 116 EjbJarProvider.needConfigurationFolder(EjbJarProjectProperties.J2EE_1_3)); 117 assertTrue("1.4 needs configuration folder", 118 EjbJarProvider.needConfigurationFolder(EjbJarProjectProperties.J2EE_1_4)); 119 assertFalse("5.0 does not need configuration folder", 120 EjbJarProvider.needConfigurationFolder(EjbJarProjectProperties.JAVA_EE_5)); 121 assertFalse("Anything else does not need configuration folder", 122 EjbJarProvider.needConfigurationFolder("5.0")); 123 assertFalse("Anything else does not need configuration folder", 124 EjbJarProvider.needConfigurationFolder("6.0.hmmm?")); 125 assertFalse("Even null does not need configuration folder", 126 EjbJarProvider.needConfigurationFolder(null)); 127 } 128 129 } 130 | Popular Tags |