added ejb artifact edit api test - commit for vkb
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/flexible/project/apitests/EJBArtifactEditTest.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/flexible/project/apitests/EJBArtifactEditTest.java index c59a0e8..1110c2d 100644 --- a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/flexible/project/apitests/EJBArtifactEditTest.java +++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/flexible/project/apitests/EJBArtifactEditTest.java
@@ -1,89 +1,127 @@ package org.eclipse.jst.j2ee.flexible.project.apitests; +import junit.framework.Assert; import junit.framework.TestCase; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.jst.j2ee.ejb.EJBJar; -import org.eclipse.jst.j2ee.ejb.EjbFactory; -import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; -import org.eclipse.jst.j2ee.internal.ejb.project.operations.EJBModuleCreationDataModel; -import org.eclipse.wtp.j2ee.headless.tests.plugin.AllPluginTests; +import org.eclipse.jst.j2ee.ejb.EJBResource; +import org.eclipse.jst.j2ee.ejb.internal.modulecore.util.EJBArtifactEdit; +import org.eclipse.wst.common.modulecore.ArtifactEditModel; +import org.eclipse.wst.common.modulecore.ModuleCoreNature; +import org.eclipse.wst.common.modulecore.UnresolveableURIException; +import org.eclipse.wst.common.modulecore.WorkbenchModule; public class EJBArtifactEditTest extends TestCase { - private IProject project; - - public void testGetJ2EEVersion() { - EJBJar jar = EjbFactory.eINSTANCE.createEJBJar(); - jar.setVersion(J2EEVersionConstants.J2EE_1_4_TEXT); - jar.getJ2EEVersionID(); - } - public void testGetDeploymentDescriptorResource() { - //IProject project = getEJBProject("Foo"); - } - - public IProject createEJBProject(String aProjectName) throws Exception { - project = ResourcesPlugin.getWorkspace().getRoot().getProject(aProjectName); - if (!project.exists()) { - EJBModuleCreationDataModel dataModel = new EJBModuleCreationDataModel(); - dataModel.setProperty(EJBModuleCreationDataModel.PROJECT_NAME, aProjectName); - dataModel.setProperty(EJBModuleCreationDataModel.IS_FLEXIBLE_PROJECT, Boolean.TRUE); - dataModel.setProperty(EJBModuleCreationDataModel.ADD_TO_EAR, Boolean.FALSE); - dataModel.setProperty(EJBModuleCreationDataModel.ADD_SERVER_TARGET, Boolean.FALSE); - dataModel.setProperty(EJBModuleCreationDataModel.SERVER_TARGET_ID, AllPluginTests.JONAS_SERVER.getId()); - dataModel.getDefaultOperation().run(null); - } - return ResourcesPlugin.getWorkspace().getRoot().getProject(aProjectName); - } - - public IProject getEJBProject(String aProjectName) throws Exception { - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(aProjectName); - if (!project.exists()) - project = createEJBProject(aProjectName); - return project; - } + public void test_EJBArtifactEdit() { - public void testGetDeploymentDescriptorRoot() { - //TODO Implement getDeploymentDescriptorRoot(). - } + ArtifactEditModel model = null; + EJBArtifactEdit tmpEJBArtifactEdit = new EJBArtifactEdit(model); + Assert.assertNotNull(tmpEJBArtifactEdit); + } - /* - * Class under test for void EJBArtifactEdit(ArtifactEditModel) - */ - public void testEJBArtifactEditArtifactEditModel() { - //TODO Implement EJBArtifactEdit(). - } + public void test_EJBArtifactEdit_2() { - /* - * Class under test for void EJBArtifactEdit(ModuleCoreNature, WorkbenchModule, boolean) - */ - public void testEJBArtifactEditModuleCoreNatureWorkbenchModuleboolean() { - //TODO Implement EJBArtifactEdit(). - } + ModuleCoreNature aNature = null; + WorkbenchModule aModule = null; + boolean toAccessAsReadOnly = false; + EJBArtifactEdit tmpEJBArtifactEdit = new EJBArtifactEdit(aNature, + aModule, toAccessAsReadOnly); + Assert.assertNotNull(tmpEJBArtifactEdit); + } - public void testGetEJBJarXmiResource() { - //TODO Implement getEJBJarXmiResource(). - } + public void test_getEJBJarXmiResource() { - public void testGetEJBJar() { - //TODO Implement getEJBJar(). - } + ModuleCoreNature aNature = null; + WorkbenchModule aModule = null; + boolean toAccessAsReadOnly = false; + EJBArtifactEdit objEJBArtifactEdit = new EJBArtifactEdit(aNature, + aModule, toAccessAsReadOnly); + EJBResource retValue = null; + retValue = objEJBArtifactEdit.getEJBJarXmiResource(); + Assert.assertNotNull(retValue); + + } - public void testAddEJBJarIfNecessary() { - //TODO Implement addEJBJarIfNecessary(). - } + public void test_getJ2EEVersion() { - public void testGetEJBArtifactEditForRead() { - //TODO Implement getEJBArtifactEditForRead(). - } + ModuleCoreNature aNature = null; + WorkbenchModule aModule = null; + boolean toAccessAsReadOnly = false; + EJBArtifactEdit objEJBArtifactEdit = new EJBArtifactEdit(aNature,aModule, toAccessAsReadOnly); + int retValue = 0; + retValue = objEJBArtifactEdit.getJ2EEVersion(); + if(retValue == -1) + Assert.assertFalse("Incorrect EJB Module version",false); + } - public void testGetEJBArtifactEditForWrite() { - //TODO Implement getEJBArtifactEditForWrite(). - } + public void test_getDeploymentDescriptorResource() { + ModuleCoreNature aNature = null; + WorkbenchModule aModule = null; + boolean toAccessAsReadOnly = false; + EJBArtifactEdit objEJBArtifactEdit = new EJBArtifactEdit(aNature, + aModule, toAccessAsReadOnly); + Resource retValue = null; + retValue = objEJBArtifactEdit.getDeploymentDescriptorResource(); + Assert.assertNotNull(retValue); + } - public void testIsValidEJBModule() { - //TODO Implement isValidEJBModule(). - } + public void test_getEJBJar() { + + ModuleCoreNature aNature = null; + WorkbenchModule aModule = null; + boolean toAccessAsReadOnly = false; + EJBArtifactEdit objEJBArtifactEdit = new EJBArtifactEdit(aNature, + aModule, toAccessAsReadOnly); + EJBJar retValue = null; + retValue = objEJBArtifactEdit.getEJBJar(); + Assert.assertNotNull(retValue); + } + + public void test_getDeploymentDescriptorRoot() { + + ModuleCoreNature aNature = null; + WorkbenchModule aModule = null; + boolean toAccessAsReadOnly = false; + EJBArtifactEdit objEJBArtifactEdit = new EJBArtifactEdit(aNature, + aModule, toAccessAsReadOnly); + EObject retValue = null; + retValue = objEJBArtifactEdit.getDeploymentDescriptorRoot(); + Assert.assertNotNull(retValue); + } + + public void test_getEJBArtifactEditForRead() { + EJBArtifactEdit retValue = null; + try{ + WorkbenchModule aModule = null; + retValue = null; + retValue = EJBArtifactEdit.getEJBArtifactEditForRead(aModule); + Assert.assertNotNull(retValue); + } finally { + retValue.dispose(); + } + } + + public void test_getEJBArtifactEditForWrite() { + EJBArtifactEdit retValue = null; + try { + WorkbenchModule aModule = null; + retValue = null; + retValue = EJBArtifactEdit.getEJBArtifactEditForWrite(aModule); + Assert.assertNotNull(retValue); + } finally { + retValue.dispose(); + } + + } + + public void test_isValidEJBModule() throws UnresolveableURIException { + WorkbenchModule aModule = null; + boolean retValue = false; + retValue = EJBArtifactEdit.isValidEJBModule(aModule); + Assert.assertTrue(retValue); + } }