Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse')
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/AllDOMTests.java59
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/AllSAXTests.java59
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/AllTests.java33
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/AppClientEMFEditTest.java64
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/AppClientEMFTest.java124
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/EarEMFEditTest.java117
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/EarEMFTest.java170
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/EjbEMFEditTest.java321
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/EjbEMFTest.java347
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/GeneralEMFEditingTest.java479
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/GeneralEMFPopulationTest.java490
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/GeneralEMFTest.java76
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/RarEMFEditTest.java63
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/RarEMFTest.java141
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/ResolverTest.java264
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/WarEMFEditTest.java139
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/WarEMFTest.java224
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/WebServicesEMFTest.java227
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/AbstractArchiveTest.java84
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/AllArchiveTestsEclipse.java20
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/AllArchiveTestsJava.java58
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/ClientContainerResourceLoadTest.java106
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/CopyTests.java234
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/DefectVerificationTests.java389
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/DiscriminatorTest.java107
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/DomComparitor.java285
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/InitializationTests.java90
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/JavaTests.java61
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/LooseArchiveTests.java282
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/RarFileTests.java207
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/ResourceTests.java112
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/SaveTests.java106
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/SecurityRoleTests.java119
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/SimpleTests.java433
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/TestInvalidXmlMultiplicity.java79
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/TestModuleClassLoading.java108
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/WARFileTests.java108
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/testutilities/EAttributeDescriptor.java70
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/testutilities/EMFAttributeFeatureGenerator.java462
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/testutilities/J2EEVersionCheck.java210
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/testutilities/TestUtilities.java115
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/core/tests/bvt/AutomatedBVT.java68
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/core/tests/bvt/AutomatedBVTEclipse.java34
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/emfload/LoadJaxRPCMapOutsideWorkspace.java96
-rw-r--r--tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/emfload/LoadWebServicesOutsideWorkspace.java93
45 files changed, 0 insertions, 7533 deletions
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/AllDOMTests.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/AllDOMTests.java
deleted file mode 100644
index 49b7420c..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/AllDOMTests.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Created on Sep 5, 2003
- *
- */
-package org.eclipse.jst.j2ee.archive.emftests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.wst.common.internal.emf.resource.EMF2DOMRendererFactory;
-
-/**
- * @author Administrator
- */
-public class AllDOMTests extends TestSuite {
-
-// private RendererFactory defaultRendererFactory;
-
-// public AllDOMTests(String name) {
-// super(name);
-// }
-
-// public AllDOMTests(String name, RendererFactory rf) {
-// super(name);
-// this.defaultRendererFactory = rf;
-// }
-
- public static Test suite() {
- TestSuite suite = new TestSuite("All DOM Tests for com.ibm.etools.archive.emftest");
- //$JUnit-BEGIN$
- suite.addTest(AppClientEMFEditTest.suite(EMF2DOMRendererFactory.INSTANCE));
- suite.addTest(AppClientEMFTest.suite(EMF2DOMRendererFactory.INSTANCE));
- suite.addTest(EarEMFEditTest.suite(EMF2DOMRendererFactory.INSTANCE));
- suite.addTest(EarEMFTest.suite(EMF2DOMRendererFactory.INSTANCE)); //
- suite.addTest(EjbEMFEditTest.suite(EMF2DOMRendererFactory.INSTANCE));
- suite.addTest(EjbEMFTest.suite(EMF2DOMRendererFactory.INSTANCE));
- suite.addTest(RarEMFEditTest.suite(EMF2DOMRendererFactory.INSTANCE));
- suite.addTest(RarEMFTest.suite(EMF2DOMRendererFactory.INSTANCE));
- suite.addTest(WarEMFEditTest.suite(EMF2DOMRendererFactory.INSTANCE));
- suite.addTest(WarEMFTest.suite(EMF2DOMRendererFactory.INSTANCE));
- suite.addTest(WebServicesEMFTest.suite(EMF2DOMRendererFactory.INSTANCE));
- //$JUnit-END$
- return suite;
- }
-
- public static void main(java.lang.String[] args) {
- junit.textui.TestRunner.main(new String[] { AllDOMTests.class.getName() });
- }
-
-// public void testSwitchRenderer() {
-// RendererFactory.setDefaultRendererFactory(EMF2DOMRendererFactory.INSTANCE);
-//
-// }
-//
-// public void testSwitchRendererBack() {
-// RendererFactory.setDefaultRendererFactory(defaultRendererFactory);
-// }
-
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/AllSAXTests.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/AllSAXTests.java
deleted file mode 100644
index a59f66fd..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/AllSAXTests.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Created on Sep 5, 2003
- *
- */
-package org.eclipse.jst.j2ee.archive.emftests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.wst.common.internal.emf.resource.EMF2SAXRendererFactory;
-
-/**
- * @author Administrator
- */
-public class AllSAXTests extends TestSuite{
-
-// private RendererFactory defaultRendererFactory;
-//
-// AllTests tests = new AllTests(); // force the class to load if this test is loaded
-//
-// public AllSAXTests(String name) {
-// super(name);
-// }
-//
-// public AllSAXTests(String name, RendererFactory rf) {
-// super(name);
-// this.defaultRendererFactory = rf;
-// }
-
- public static Test suite() {
- TestSuite suite = new TestSuite("All SAX Tests for com.ibm.etools.archive.emftest");
- //$JUnit-BEGIN$
- suite.addTest(AppClientEMFEditTest.suite(EMF2SAXRendererFactory.INSTANCE));
- suite.addTest(AppClientEMFTest.suite(EMF2SAXRendererFactory.INSTANCE));
- suite.addTest(EarEMFEditTest.suite(EMF2SAXRendererFactory.INSTANCE));
- suite.addTest(EarEMFTest.suite(EMF2SAXRendererFactory.INSTANCE)); //
- suite.addTest(EjbEMFEditTest.suite(EMF2SAXRendererFactory.INSTANCE));
- suite.addTest(EjbEMFTest.suite(EMF2SAXRendererFactory.INSTANCE));
- suite.addTest(RarEMFEditTest.suite(EMF2SAXRendererFactory.INSTANCE));
- suite.addTest(RarEMFTest.suite(EMF2SAXRendererFactory.INSTANCE));
- suite.addTest(WarEMFEditTest.suite(EMF2SAXRendererFactory.INSTANCE));
- suite.addTest(WarEMFTest.suite(EMF2SAXRendererFactory.INSTANCE));
- suite.addTest(WebServicesEMFTest.suite(EMF2SAXRendererFactory.INSTANCE));
- //$JUnit-END$
- return suite;
- }
-
- public static void main(java.lang.String[] args) {
- junit.textui.TestRunner.main(new String[] { AllSAXTests.class.getName() });
- }
-
-// public void testSwitchRenderer() {
-// RendererFactory.setDefaultRendererFactory(EMF2SAXRendererFactory.INSTANCE);
-// }
-//
-// public void testSwitchRendererBack() {
-// RendererFactory.setDefaultRendererFactory(defaultRendererFactory);
-// }
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/AllTests.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/AllTests.java
deleted file mode 100644
index 7e3008bf..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/AllTests.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Created on Apr 1, 2003
- *
- * To change this generated comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.jst.j2ee.archive.emftests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * To change this generated comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class AllTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite("Test for Common Archive and EMF Tests");
- //$JUnit-BEGIN$
-
- suite.addTest(AllDOMTests.suite());
- suite.addTest(AllSAXTests.suite());
-
- //$JUnit-END$
- return suite;
- }
-
- public static void main(java.lang.String[] args) {
- junit.textui.TestRunner.main(new String[] { AllTests.class.getName() });
- }
-
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/AppClientEMFEditTest.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/AppClientEMFEditTest.java
deleted file mode 100644
index 28679d42..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/AppClientEMFEditTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package org.eclipse.jst.j2ee.archive.emftests;
-
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-
-import org.eclipse.jst.j2ee.client.ApplicationClientResource;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.ApplicationClientFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.DuplicateObjectException;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-import org.eclipse.wst.common.internal.emf.resource.RendererFactory;
-
-
-public class AppClientEMFEditTest extends GeneralEMFEditingTest {
- EARFile earFile;
- ApplicationClientFile appClientFile;
-
- public AppClientEMFEditTest(String name) {
- super(name);
- }
-
- public AppClientEMFEditTest(String name, RendererFactory factory) {
- super(name, factory);
- }
-
- public static void main(java.lang.String[] args) {
- String[] className = { "com.ibm.etools.archive.test.AppClientEMFEditTest", "-noloading" };
- TestRunner.main(className);
- }
-
- public static junit.framework.Test suite(RendererFactory factory) {
- TestSuite suite = new TestSuite(AppClientEMFEditTest.class.getName());
- suite.addTest(new AppClientEMFEditTest("testApplicationClientEdit", factory));
- return suite;
- }
-
- public void testApplicationClientEdit() throws Exception {
- getAppClient();
- assertEquals("1.3", appClientFile.getDeploymentDescriptor().getVersion());
-
- ApplicationClientResource DD = (ApplicationClientResource) appClientFile.getDeploymentDescriptorResource();
- setVersion(VERSION_1_3);
- setModuleType(APP_CLIENT);
- editRoot(DD.getRootObject());
- String curDir = AutomatedBVT.baseDirectory;
- String out = curDir + "testOutput/EMFModelCreationTests/EditAppEAR";
- appClientFile.extractTo(out, Archive.EXPAND_ALL);
- appClientFile.close();
-
- //Compare
-
- String exampleDeploymentDesURI = curDir + "EMFTests/application-client.xml";
- String curDeploymentDesURI = curDir + out + "/AppClientfoo/META-INF/application-client.xml";
- setIgnoreAtt(ignorableAttributes());
- //compareContents(curDeploymentDesURI, exampleDeploymentDesURI);
- }
-
- public void getAppClient() throws DuplicateObjectException, OpenFailureException {
- String in = AutomatedBVT.baseDirectory + "loose_module_workspace/LooseEARApp/fooAPP/";
- appClientFile = getArchiveFactory().openApplicationClientFile(in);
- }
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/AppClientEMFTest.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/AppClientEMFTest.java
deleted file mode 100644
index 0048ef3d..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/AppClientEMFTest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.archive.emftests;
-
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-
-import org.eclipse.jst.j2ee.archive.testutilities.EMFAttributeFeatureGenerator;
-import org.eclipse.jst.j2ee.client.ApplicationClientResource;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.ApplicationClientFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.DuplicateObjectException;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
-import org.eclipse.wst.common.internal.emf.resource.RendererFactory;
-
-
-public class AppClientEMFTest extends GeneralEMFPopulationTest {
- EARFile earFile;
- protected ApplicationClientFile appClientFile;
- EARFile earFile14;
- ApplicationClientFile appClientFile14;
-
- public AppClientEMFTest(String name) {
- super(name);
- }
-
- public AppClientEMFTest(String name, RendererFactory factory) {
- super(name, factory);
- }
-
- public static void main(java.lang.String[] args) {
- String[] className = { "com.ibm.etools.archive.test.AppClientEMFTest", "-noloading" };
- TestRunner.main(className);
- }
-
- public static junit.framework.Test suite(RendererFactory factory) {
- TestSuite suite = new TestSuite(AppClientEMFTest.class.getName());
- //[248158] suite.addTest(new AppClientEMFTest("testApplicationClientPopulation", factory));
- suite.addTest(new AppClientEMFTest("test14ApplicationClientPopulation", factory));
- return suite;
- }
-
- public void testApplicationClientPopulation() throws Exception {
- EMFAttributeFeatureGenerator.reset();
- createEAR();
- createAppClient();
-
- ApplicationClientResource DD = (ApplicationClientResource) appClientFile.getDeploymentDescriptorResource();
- DD.setVersionID(J2EEVersionConstants.J2EE_1_3_ID);
- setVersion(VERSION_1_3);
- setModuleType(APP_CLIENT);
- populateRoot(DD.getRootObject());
-
- String out = AutomatedBVT.baseDirectory +"testOutput/TestAppEAR";
- earFile.extractTo(out, Archive.EXPAND_ALL);
- earFile.close();
-
- //Compare
- String curDir = AutomatedBVT.baseDirectory;
- String exampleDeploymentDesURI = curDir + "EMFTestNoID/application-client.xml";
- String curDeploymentDesURI = curDir + "testOutput/TestAppEAR/fooAPP/META-INF/application-client.xml";
- setIgnoreAtt(ignorableAttributes());
- compareContentsIgnoreWhitespace(curDeploymentDesURI, exampleDeploymentDesURI, null);
- }
-
- public void test14ApplicationClientPopulation() throws Exception {
- EMFAttributeFeatureGenerator.reset();
- createEAR();
- createAppClient();
-
- ApplicationClientResource DD = (ApplicationClientResource) appClientFile.getDeploymentDescriptorResource();
- DD.setVersionID(J2EEVersionConstants.J2EE_1_4_ID);
- setVersion(VERSION_1_4);
- setModuleType(APP_CLIENT);
- populateRoot(DD.getRootObject());
-
- String out = AutomatedBVT.baseDirectory +"testOutput/TestAppEAR14";
- earFile.extractTo(out, Archive.EXPAND_ALL);
- earFile.close();
-
- getApp14Client();
- assertEquals("1.4", appClientFile14.getDeploymentDescriptor().getVersion());
- out = AutomatedBVT.baseDirectory +"testOutput/TestAppEAR14_2";
- appClientFile14.extractTo(out, Archive.EXPAND_ALL);
- appClientFile14.close();
-
- //Compare
- String curDir = AutomatedBVT.baseDirectory;
- String curDeploymentDesURI = curDir + "testOutput/TestAppEAR14/fooAPP/META-INF/application-client.xml";
- String secondDeploymentDesURI = out + "/META-INF/application-client.xml";
- setIgnoreAtt(ignorableAttributes());
- compareContentsIgnoreWhitespace(curDeploymentDesURI, secondDeploymentDesURI, null);
- }
-
- public void createAppClient() throws DuplicateObjectException {
- appClientFile = getArchiveFactory().createApplicationClientFileInitialized("fooAPP");
- appClientFile = (ApplicationClientFile) earFile.addCopy(appClientFile);
- appClientFile.getDeploymentDescriptor().setDisplayName("fooAPP");
- assertTrue(appClientFile.getDeploymentDescriptor() != null);
- }
-
- public void createEAR() {
- String earName = "Test.ear";
- earFile = getArchiveFactory().createEARFileInitialized(earName);
- assertTrue(earFile.getDeploymentDescriptor() != null);
- }
-
-
- public void getApp14Client() throws DuplicateObjectException, OpenFailureException {
- String in = AutomatedBVT.baseDirectory + "testOutput/TestAppEAR14/fooAPP";
- appClientFile14 = getArchiveFactory().openApplicationClientFile(in);
- }
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/EarEMFEditTest.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/EarEMFEditTest.java
deleted file mode 100644
index 9bd5791d..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/EarEMFEditTest.java
+++ /dev/null
@@ -1,117 +0,0 @@
-package org.eclipse.jst.j2ee.archive.emftests;
-
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.jst.j2ee.application.ApplicationFactory;
-import org.eclipse.jst.j2ee.application.ApplicationResource;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-import org.eclipse.wst.common.internal.emf.resource.RendererFactory;
-
-
-public class EarEMFEditTest extends GeneralEMFEditingTest {
- EARFile earFile;
- int createdModules = 0;
-
- private int NUM_MODULES = 4;
-
- public EarEMFEditTest(String name) {
- super(name);
- }
-
- public EarEMFEditTest(String name, RendererFactory factory) {
- super(name, factory);
- }
-
- public static void main(java.lang.String[] args) {
- String[] className = { "com.ibm.etools.archive.test.EarEMFEditTest", "-noloading" };
- TestRunner.main(className);
- }
-
- public static junit.framework.Test suite(RendererFactory factory) {
- TestSuite suite = new TestSuite(EarEMFEditTest.class.getName());
- suite.addTest(new EarEMFEditTest("testEAREdit", factory));
- return suite;
- }
-
- public void testEAREdit() throws Exception {
- getEAR();
-
- assertEquals("1.2", earFile.getDeploymentDescriptor().getVersion());
-
- ApplicationResource DD = (ApplicationResource) earFile.getDeploymentDescriptorResource();
- setVersion(VERSION_1_3);
- setModuleType(APPICATION);
- editRoot(DD.getRootObject());
- String curDir = AutomatedBVT.baseDirectory;
-
- String out = curDir +"testOutput/EditOutput/EMFModelCreationTests/EditEAR";
- earFile.extractTo(out, Archive.EXPAND_ALL);
- earFile.close();
-
- //Compare work in progress
-
- String exampleDeploymentDesURI = curDir + "EMFTests/application.xml";
- String curDeploymentDesURI = curDir + out + "/META-INF/application.xml";
- //compareContents(curDeploymentDesURI, exampleDeploymentDesURI);
- }
-
- public void getEAR() throws OpenFailureException {
- String in = AutomatedBVT.baseDirectory + "loose_module_workspace/LooseEAR/";
- earFile = getArchiveFactory().openEARFile(in);
- assertTrue(earFile.getDeploymentDescriptor() != null);
- }
-
- public EObject createInstance(EClass eClassifier) {
- if (eClassifier.getName().equals("Module")) {
- createdModules++;
- switch (createdModules) {
- case (1) :
- return createJavaModuleInstance(eClassifier);
- case (2) :
- return createEJBModuleInstance(eClassifier);
- case (3) :
- return createWebModuleInstance(eClassifier);
- case (4) :
- return createConnetorModuleInstance(eClassifier);
- default :
- return createJavaModuleInstance(eClassifier);
- }
- }
- return super.createInstance(eClassifier);
- }
-
- private EObject createConnetorModuleInstance(EClass eClassifier) {
- return ((ApplicationFactory) eClassifier.getEPackage().getEFactoryInstance()).createConnectorModule();
- }
-
- private EObject createWebModuleInstance(EClass eClassifier) {
- return ((ApplicationFactory) eClassifier.getEPackage().getEFactoryInstance()).createWebModule();
- }
-
- private EObject createEJBModuleInstance(EClass eClassifier) {
- return ((ApplicationFactory) eClassifier.getEPackage().getEFactoryInstance()).createEjbModule();
- }
-
- private EObject createJavaModuleInstance(EClass eClassifier) {
- return ((ApplicationFactory) eClassifier.getEPackage().getEFactoryInstance()).createJavaClientModule();
- }
-
- public Object getSharedObjectByType(EObject owner, EReference ref) {
- if (ref.getName().equals("module"))
- return createJavaModuleInstance((EClass) ref.getEType());
- return super.getSharedObjectByType(owner, ref);
- }
-
- public int getDepthForAttribute(EReference ref) {
- if (ref.getName().equals("modules"))
- return NUM_MODULES;
- return super.getDepthForAttribute(ref);
- }
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/EarEMFTest.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/EarEMFTest.java
deleted file mode 100644
index 39f44721..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/EarEMFTest.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.archive.emftests;
-
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.jst.j2ee.application.ApplicationFactory;
-import org.eclipse.jst.j2ee.application.ApplicationResource;
-import org.eclipse.jst.j2ee.archive.testutilities.EMFAttributeFeatureGenerator;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
-import org.eclipse.wst.common.internal.emf.resource.RendererFactory;
-
-
-public class EarEMFTest extends GeneralEMFPopulationTest {
- protected EARFile earFile;
- int createdModules = 0;
-
- private int NUM_MODULES = 5;
-
- public EarEMFTest(String name) {
- super(name);
- }
-
- public EarEMFTest(String name, RendererFactory factory) {
- super(name, factory);
- }
-
- public static void main(java.lang.String[] args) {
- String[] className = { "com.ibm.etools.archive.test.EarEMFTest", "-noloading" };
- TestRunner.main(className);
- }
-
- public static junit.framework.Test suite(RendererFactory factory) {
- TestSuite suite = new TestSuite(EarEMFTest.class.getName());
- //[248158] suite.addTest(new EarEMFTest("testEARPopulation", factory));
- suite.addTest(new EarEMFTest("test14EARPopulation", factory));
- return suite;
- }
-
- public void testEARPopulation() throws Exception {
- EMFAttributeFeatureGenerator.reset();
- createEAR();
- //createAppClient();
-
- ApplicationResource DD = (ApplicationResource) earFile.getDeploymentDescriptorResource();
- //TODO: individual test for each version
- DD.setVersionID(J2EEVersionConstants.J2EE_1_3_ID);
- setVersion(VERSION_1_3);
- setModuleType(APPLICATION);
- populateRoot(DD.getRootObject());
-
- String out = AutomatedBVT.baseDirectory +"testOutput/TestEAR";
- earFile.extractTo(out, Archive.EXPAND_ALL);
- earFile.close();
-
- //Compare work in progress
- String curDir = AutomatedBVT.baseDirectory;
- String exampleDeploymentDesURI = curDir + "EMFTestNoID/application.xml";
- String curDeploymentDesURI = curDir + "testOutput/TestEAR/META-INF/application.xml";
- setIgnoreAtt(ignorableAttributes());
- compareContentsIgnoreWhitespace(curDeploymentDesURI, exampleDeploymentDesURI, null);
- }
-
- public void test14EARPopulation() throws Exception {
- EMFAttributeFeatureGenerator.reset();
- createEAR();
- //createAppClient();
-
- ApplicationResource DD = (ApplicationResource) earFile.getDeploymentDescriptorResource();
- //TODO: individual test for each version
- DD.setVersionID(J2EEVersionConstants.J2EE_1_4_ID);
- setVersion(VERSION_1_4);
- setModuleType(APPLICATION);
- populateRoot(DD.getRootObject());
-
- String out = AutomatedBVT.baseDirectory +"testOutput/TestEAR14";
- earFile.extractTo(out, Archive.EXPAND_ALL);
- earFile.close();
-
- getEAR();
- assertEquals("1.4", earFile.getDeploymentDescriptor().getVersion());
- out = AutomatedBVT.baseDirectory +"testOutput/TestEAR14_2";
- earFile.extractTo(out, Archive.EXPAND_ALL);
-
- earFile.close();
-
- //Compare work in progress
- String curDir = AutomatedBVT.baseDirectory;
- String exampleDeploymentDesURI = out + "/META-INF/application.xml";
- String curDeploymentDesURI = curDir + "testOutput/TestEAR14/META-INF/application.xml";
- setIgnoreAtt(ignorableAttributes());
- compareContentsIgnoreWhitespace(curDeploymentDesURI, exampleDeploymentDesURI, null);
- }
- public void createEAR() {
- String earName = "Test.ear";
- earFile = getArchiveFactory().createEARFileInitialized(earName);
- assertTrue(earFile.getDeploymentDescriptor() != null);
- }
-
- public void getEAR() throws OpenFailureException {
- String in =AutomatedBVT.baseDirectory +"testOutput/TestEAR14";
- earFile = getArchiveFactory().openEARFile(in);
- assertTrue(earFile.getDeploymentDescriptor() != null);
- }
-
- public EObject createInstance(EReference ref, EObject eObject) {
- EClass eClassifier = (EClass)ref.getEType();
- if (eClassifier.getName().equals("Module")) {
- createdModules++;
- switch (createdModules) {
- case (1) :
- return createJavaModuleInstance(eClassifier);
- case (2) :
- return createEJBModuleInstance(eClassifier);
- case (3) :
- return createWebModuleInstance(eClassifier);
- case (4) :
- return createConnetorModuleInstance(eClassifier);
- default :
- return createJavaModuleInstance(eClassifier);
- }
- }
- return super.createInstance(ref,eObject);
- }
-
- private EObject createConnetorModuleInstance(EClass eClassifier) {
- return ((ApplicationFactory) eClassifier.getEPackage().getEFactoryInstance()).createConnectorModule();
- }
-
- private EObject createWebModuleInstance(EClass eClassifier) {
- return ((ApplicationFactory) eClassifier.getEPackage().getEFactoryInstance()).createWebModule();
- }
-
- private EObject createEJBModuleInstance(EClass eClassifier) {
- return ((ApplicationFactory) eClassifier.getEPackage().getEFactoryInstance()).createEjbModule();
- }
-
- private EObject createJavaModuleInstance(EClass eClassifier) {
- return ((ApplicationFactory) eClassifier.getEPackage().getEFactoryInstance()).createJavaClientModule();
- }
-
- public Object getSharedObjectByType(EObject owner, EReference ref) {
- if (ref.getName().equals("module"))
- return createJavaModuleInstance((EClass) ref.getEType());
- return super.getSharedObjectByType(owner, ref);
- }
-
- public int getDepthForAttribute(EStructuralFeature ref) {
- if (ref.getName().equals("modules"))
- return NUM_MODULES;
- return super.getDepthForAttribute(ref);
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/EjbEMFEditTest.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/EjbEMFEditTest.java
deleted file mode 100644
index a00cf1b0..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/EjbEMFEditTest.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.archive.emftests;
-
-import java.util.List;
-
-import junit.framework.TestSuite;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.jst.j2ee.archive.testutilities.EMFAttributeFeatureGenerator;
-import org.eclipse.jst.j2ee.common.CommonFactory;
-import org.eclipse.jst.j2ee.common.SecurityIdentity;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EJBJarFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.DuplicateObjectException;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveOptions;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-import org.eclipse.jst.j2ee.ejb.CMPAttribute;
-import org.eclipse.jst.j2ee.ejb.EJBResource;
-import org.eclipse.jst.j2ee.ejb.EjbFactory;
-import org.eclipse.jst.j2ee.ejb.EjbPackage;
-import org.eclipse.jst.j2ee.ejb.RoleSource;
-import org.eclipse.jst.j2ee.ejb.internal.impl.MethodPermissionImpl;
-import org.eclipse.jst.j2ee.ejb.internal.impl.QueryMethodImpl;
-import org.eclipse.wst.common.internal.emf.resource.EMF2SAXRendererFactory;
-import org.eclipse.wst.common.internal.emf.resource.RendererFactory;
-
-
-public class EjbEMFEditTest extends GeneralEMFEditingTest {
-
- protected static final EjbPackage EJB_PKG = EjbPackage.eINSTANCE;
- EARFile earFile;
- EJBJarFile ejbFile;
- EObject mesBean, entityBean;
- SecurityIdentity secID;
- RoleSource roleSource;
- int NUM_BEANS = 10;
- final int NUM_RELATION_ROLES = 2;
- int createdBeans = 0;
- int createdSecRoles = 0;
- protected int createdSecurityIdentities = 0;
- boolean mpFlag = false;
-
- public EjbEMFEditTest(String name) {
- super(name);
- }
-
- public EjbEMFEditTest(String name, RendererFactory factory) {
- super(name, factory);
- }
-
- public static void main(java.lang.String[] args) {
- junit.textui.TestRunner.main(new String[] { EjbEMFEditTest.class.getName() });
- }
-
- public static junit.framework.Test suite(RendererFactory factory) {
- TestSuite suite = new TestSuite(EjbEMFEditTest.class.getName());
- suite.addTest(new EjbEMFEditTest("testEJBJarEdit",factory));
- suite.addTest(new EjbEMFEditTest("testWCCMJar",factory));
- return suite;
- }
-
- public void testEJBJarEdit() throws Exception {
- getEJB();
-
- assertEquals("2.0", ejbFile.getDeploymentDescriptor().getVersion());
- EJBResource DD = (EJBResource) ejbFile.getDeploymentDescriptorResource();
- setVersion(VERSION_1_3);
- setModuleType(EJB);
- editRoot(DD.getRootObject());
- String curDir = AutomatedBVT.baseDirectory;
- String out = curDir + "testOutput/EMFModelCreationTests/EditEjbEAR";
- ejbFile.extractTo(out, Archive.EXPAND_ALL);
- ejbFile.close();
-
-
- //Compare work in progress
-
- String exampleDeploymentDesURI = null;
- //System.out.println(RendererFactory.getDefaultRendererFactory());
- if (RendererFactory.getDefaultRendererFactory() instanceof EMF2SAXRendererFactory){
- exampleDeploymentDesURI = curDir + "EMFTests/ejb-jar2-0sax.xml";
- }
- else
- exampleDeploymentDesURI = curDir + "EMFTests/ejb-jar2-0.xml";
- //System.out.println("File: " + exampleDeploymentDesURI);
- String curDeploymentDesURI = out + "/META-INF/ejb-jar.xml";
- //TODO Remove after webservices xsd is restored
- //compareContentsIgnoreWhitespace(curDeploymentDesURI, exampleDeploymentDesURI, "");
- }
-
- public void testWCCMJar() throws Exception {
- String in = AutomatedBVT.baseDirectory + "../testData/ejb";
- ArchiveOptions options = new ArchiveOptions();
- options.setIsReadOnly(true);
- ejbFile = getArchiveFactory().openEJBJarFile(options, in);
-
- EJBResource DD = (EJBResource) ejbFile.getDeploymentDescriptorResource();
- DD.getRootObject();
-
- String out = AutomatedBVT.baseDirectory + "../testData/testOutput";
- ejbFile.extractTo(out, Archive.EXPAND_ALL);
- ejbFile.close();
-
- /*DD.save(System.out, null); */
-
- //Compare work in progress
- String curDir = AutomatedBVT.baseDirectory;
- String exampleDeploymentDesURI = in + "/META-INF/ejb-jar.xml";
- String curDeploymentDesURI = out + "/META-INF/ejb-jar.xml";
-
- compareContents(curDeploymentDesURI, exampleDeploymentDesURI);
- }
-
- /**
- * Requires j2ee.core.ws.ext to be on the classpath
- * @throws DuplicateObjectException
- * @throws OpenFailureException
- */
-/* public void testWCCMProvidedCase() throws Exception {
-
- String in = AutomatedBVT.baseDirectory + "../wccm/ear";
- EARFile earFile = null;
- try {
-
- CommonarchiveFactory factory =
- CommonarchiveFactoryImpl.getActiveFactory();
- ArchiveOptions opt = new ArchiveOptions();
- opt.setIsReadOnly (true);
- opt.setUseJavaReflection (false);
-
- earFile = factory.openEARFile (opt, in);
- System.out.println ("uri: " + earFile.getURI());
- System.out.println ("origuri: " + earFile.getOriginalURI());
-
- Application application = earFile.getDeploymentDescriptor();
- ApplicationBinding appBindings = earFile.getBindings();
- ApplicationExtension appExtensions = earFile.getExtensions();
-
-
- Iterator rs = earFile.getLoadedMofResources().iterator();
- while (rs.hasNext())
- {
- Resource r = (Resource) rs.next();
-
- FileOutputStream fo = new FileOutputStream (r.getURI().toString().replace('/', '-'));
- r.save (fo, new HashMap());
- fo.flush();
- fo.close();
- }
-
- System.out.println("==========<Done App DD>==========");
- System.out.println ("");
-
-
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- finally {
- if(earFile != null)
- earFile.close();
- }
-
- }*/
-
- public void getEJB() throws DuplicateObjectException, OpenFailureException {
- String in = AutomatedBVT.baseDirectory + "loose_module_workspace/LooseEAREjb/ejbModule/";
- ejbFile = getArchiveFactory().openEJBJarFile(in);
- assertTrue(ejbFile.getDeploymentDescriptor() != null);
- }
-
- public EObject createInstance(EClass eClassifier) {
- if (eClassifier.getName().equals("EnterpriseBean")) {
- createdBeans++;
- switch (createdBeans) {
- case (3) :
- return createContainerManagedEntityInstance(eClassifier);
- case (7) :
- return createMessageBeanInstance(eClassifier);
- case (4) :
- case (8) :
- return createSessionBeanInstance(eClassifier);
- default :
- return createEntityBeanInstance(eClassifier);
- }
- } else if (eClassifier.getName().equals("SecurityIdentity"))
- return createSecurityIdentitiyInstance(eClassifier);
- else if (eClassifier.getName().equals("RoleSource"))
- return createRoleSourceInstance(eClassifier);
- else if (eClassifier == EcorePackage.eINSTANCE.getEAttribute())
- return getEjbFactory().createCMPAttribute();
- return super.createInstance(eClassifier);
- }
-
- private EObject createSecurityIdentitiyInstance(EClass eClassifier) {
- /* Alternate types */
- createdSecRoles++;
- if ((createdSecRoles & 1) == 0)
- return CommonFactory.eINSTANCE.createUseCallerIdentity();
- else
- return CommonFactory.eINSTANCE.createRunAsSpecifiedIdentity();
- }
-
- private EObject createRoleSourceInstance(EClass eClassifier) {
- return ((EjbFactory) eClassifier.getEPackage().getEFactoryInstance()).createRoleSource();
- }
-
- private EObject createMessageBeanInstance(EClass eClassifier) {
- return ((EjbFactory) eClassifier.getEPackage().getEFactoryInstance()).createMessageDriven();
- }
-
- private EObject createSessionBeanInstance(EClass eClassifier) {
- return ((EjbFactory) eClassifier.getEPackage().getEFactoryInstance()).createSession();
- }
-
- private EObject createEntityBeanInstance(EClass eClassifier) {
- return ((EjbFactory) eClassifier.getEPackage().getEFactoryInstance()).createEntity();
- }
-
- private EObject createContainerManagedEntityInstance(EClass eClassifier) {
- return EjbFactory.eINSTANCE.createContainerManagedEntity();
- }
-
- /**
- * @see org.eclipse.jst.j2ee.archive.test.GeneralEMFTest#getDepthForAttribute(EReference)
- */
- public int getDepthForAttribute(EReference ref) {
- if (ref.getName().equals("enterpriseBeans"))
- return NUM_BEANS;
- else if (ref.getName().equals("entityBeans"))
- return NUM_BEANS;
- else if (ref.getName().equals("relationshipRoles"))
- return NUM_RELATION_ROLES;
- return super.getDepthForAttribute(ref);
- }
-
- /* (non-Javadoc)
- * @see com.ibm.etools.archive.emftest.GeneralEMFPopulationTest#populateFeatures(org.eclipse.emf.ecore.EObject)
- */
- public void populateFeatures(EObject eObject) {
- if (eObject.eClass() == EJB_PKG.getCMPAttribute()) {
- ((CMPAttribute) eObject).setName((String) EMFAttributeFeatureGenerator.createAttribute(EcorePackage.eINSTANCE.getENamedElement_Name(),eObject));
- ((CMPAttribute) eObject).setEType((EClassifier) createJavaClassProxy(null));
- } else
- super.editFeatures(eObject);
- }
-
- /* (non-Javadoc)
- * @see com.ibm.etools.archive.emftest.GeneralEMFPopulationTest#populateAttributes(org.eclipse.emf.ecore.EObject)
- */
- protected void populateAttributes(EObject eObject) {
- if (eObject instanceof QueryMethodImpl) {
- List attributes = eObject.eClass().getEAllAttributes();
- for (int i = 0; i < attributes.size(); i++) {
- EAttribute att = (EAttribute) attributes.get(i);
- Object value = createAttributeValue(att, eObject);
- if (att.getName().equals("parms") && value == null){
- value = createAttributeValue(att, eObject);
- }
- if (att.isChangeable())
- eObject.eSet(att, value);
- }
- } else if (eObject instanceof MethodPermissionImpl) {
- List attributes = eObject.eClass().getEAllAttributes();
- for (int i = 0; i < attributes.size(); i++) {
- EAttribute att = (EAttribute) attributes.get(i);
- if(att.getName().equals("unchecked") && mpFlag){
- continue;
- }
-
- Object value = createAttributeValue(att, eObject);
- if (att.isChangeable())
- eObject.eSet(att, value);
- }
- mpFlag = !mpFlag;
- } else
- super.editAttributes(eObject);
- }
-
-
- protected void populateSharedReference(EObject eObject, EReference ref) {
- if(eObject instanceof MethodPermissionImpl && ref.getName().equals("roles")){
- mpFlag = !mpFlag;
- //if method permission unchecked ignore roles
- if(!mpFlag){
- return;
- }
- }
- super.populateSharedReference(eObject, ref);
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- earFile = null;
- ejbFile = null;
- mesBean = null;
- entityBean = null;
- secID = null;
- roleSource = null;
-
- super.tearDown();
- }
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/EjbEMFTest.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/EjbEMFTest.java
deleted file mode 100644
index c153b41d..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/EjbEMFTest.java
+++ /dev/null
@@ -1,347 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.archive.emftests;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestSuite;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.jem.java.internal.impl.JavaClassImpl;
-import org.eclipse.jst.j2ee.archive.testutilities.EMFAttributeFeatureGenerator;
-import org.eclipse.jst.j2ee.common.CommonFactory;
-import org.eclipse.jst.j2ee.common.SecurityIdentity;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EJBJarFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.DuplicateObjectException;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-import org.eclipse.jst.j2ee.ejb.CMPAttribute;
-import org.eclipse.jst.j2ee.ejb.CMRField;
-import org.eclipse.jst.j2ee.ejb.EJBResource;
-import org.eclipse.jst.j2ee.ejb.EjbFactory;
-import org.eclipse.jst.j2ee.ejb.EjbPackage;
-import org.eclipse.jst.j2ee.ejb.MethodPermission;
-import org.eclipse.jst.j2ee.ejb.RoleSource;
-import org.eclipse.jst.j2ee.ejb.internal.impl.EJBRelationshipRoleImpl;
-import org.eclipse.jst.j2ee.ejb.internal.impl.MethodPermissionImpl;
-import org.eclipse.jst.j2ee.ejb.internal.impl.QueryMethodImpl;
-import org.eclipse.jst.j2ee.internal.J2EEInit;
-import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
-import org.eclipse.wst.common.internal.emf.resource.RendererFactory;
-
-
-public class EjbEMFTest extends GeneralEMFPopulationTest {
- static {
- //Temporary workaround to keep packages from being registered twice
- J2EEInit.init();
- }
- protected static final EjbPackage EJB_PKG = EjbPackage.eINSTANCE;
- EARFile earFile;
- protected EJBJarFile ejbFile;
- EObject mesBean, entityBean;
- SecurityIdentity secID;
- RoleSource roleSource;
- int NUM_BEANS = 10;
- final int NUM_RELATION_ROLES = 2;
- int createdBeans = 0;
- int createdSecRoles = 0;
- protected int createdSecurityIdentities = 0;
- boolean mpFlag = false;
- boolean firstReturnTypeMapping = true;
-
- public EjbEMFTest(String name) {
- super(name);
- }
-
- public EjbEMFTest(String name, RendererFactory factory) {
- super(name, factory);
- }
-
- public static void main(java.lang.String[] args) {
- junit.textui.TestRunner.main(new String[] { EjbEMFTest.class.getName()});
- }
-
- public static junit.framework.Test suite(RendererFactory factory) {
- TestSuite suite = new TestSuite(EjbEMFTest.class.getName());
- //[248158] suite.addTest(new EjbEMFTest("testEJBJarPopulation",factory));
- suite.addTest(new EjbEMFTest("test14EJBJarPopulation",factory));
- return suite;
- }
-
- public void testEJBJarPopulation() throws Exception {
- EMFAttributeFeatureGenerator.reset();
- createEAR();
- createEJB();
-
- EJBResource DD = (EJBResource) ejbFile.getDeploymentDescriptorResource();
- //TODO: individual test for each version
- DD.setVersionID(J2EEVersionConstants.J2EE_1_3_ID);
- setVersion(VERSION_1_3);
- setModuleType(EJB);
- populateRoot(DD.getRootObject());
-
- String out = AutomatedBVT.baseDirectory +"testOutput/TestEJBEAR";
- earFile.extractTo(out, Archive.EXPAND_ALL);
- earFile.close();
- setEquivalentLines(getEquivalentLinesMap());
- //Compare work in progress
- String curDir = AutomatedBVT.baseDirectory;
- String exampleDeploymentDesURI = curDir + "/EMFTestNoID/ejb-jar.xml";
- String curDeploymentDesURI = curDir + "testOutput/TestEJBEAR/fooEJB/META-INF/ejb-jar.xml";
- setIgnoreAtt(ignorableAttributes());
- compareContentsIgnoreWhitespace(curDeploymentDesURI, exampleDeploymentDesURI, null);
-// DD.unload();
-// DD.load(new HashMap());
- }
-
- public void test14EJBJarPopulation() throws Exception {
- EMFAttributeFeatureGenerator.reset();
- createEAR();
- createEJB();
-
- EJBResource DD = (EJBResource) ejbFile.getDeploymentDescriptorResource();
- //TODO: individual test for each version
- DD.setVersionID(J2EEVersionConstants.J2EE_1_4_ID);
- setVersion(VERSION_1_4);
- setModuleType(EJB);
- //setGeneralDepth(2);
- populateRoot(DD.getRootObject());
- String out = AutomatedBVT.baseDirectory +"testOutput/TestEJBEAR14";
- earFile.extractTo(out, Archive.EXPAND_ALL);
- earFile.close();
-
- setEquivalentLines(getEquivalentLinesMap());
- getEJB();
- assertEquals("2.1", ejbFile.getDeploymentDescriptor().getVersion());
- out = AutomatedBVT.baseDirectory +"testOutput/TestEJBEAR14_2";
- ejbFile.extractTo(out, Archive.EXPAND_ALL);
- ejbFile.close();
-
- //Compare work in progress
- String curDir = AutomatedBVT.baseDirectory;
- String exampleDeploymentDesURI = out + "/META-INF/ejb-jar.xml";
- String curDeploymentDesURI = curDir + "testOutput/TestEJBEAR14/fooEJB/META-INF/ejb-jar.xml";
- setIgnoreAtt(ignorableAttributes());
- compareContentsIgnoreWhitespace(curDeploymentDesURI, exampleDeploymentDesURI, null);
- }
-
- /**
- * @return
- */
- private Map getEquivalentLinesMap() {
- Map lines = new HashMap();
- lines.put("<cascade-delete></cascade-delete>", "<cascade-delete/>");
- lines.put("<method-params></method-params>","<method-params/>");
- lines.put("<unchecked></unchecked>","<unchecked/>");
- lines.put("<use-caller-identity></use-caller-identity>","<use-caller-identity/>");
- return lines;
- }
-
- public void getEJB() throws DuplicateObjectException, OpenFailureException {
- String in = AutomatedBVT.baseDirectory +"testOutput/TestEJBEAR14/fooEJB";
- ejbFile = getArchiveFactory().openEJBJarFile(in);
- assertTrue(ejbFile.getDeploymentDescriptor() != null);
- }
-
- public void createEJB() throws DuplicateObjectException {
- ejbFile = getArchiveFactory().createEJBJarFileInitialized("fooEJB");
- ejbFile = (EJBJarFile) earFile.addCopy(ejbFile);
- ejbFile.getDeploymentDescriptor().setDisplayName("fooEJB");
- assertTrue(ejbFile.getDeploymentDescriptor() != null);
- }
-
- public void createEAR() {
- String earName = "Test.ear";
- earFile = getArchiveFactory().createEARFileInitialized(earName);
- assertTrue(earFile.getDeploymentDescriptor() != null);
- }
-
- public EObject createInstance(EReference ref, EObject eObject) {
- EClass eClassifier = (EClass)ref.getEType();
- if (eClassifier.getName().equals("EnterpriseBean")) {
- createdBeans++;
- switch (createdBeans) {
- case (3) :
- return createContainerManagedEntityInstance(eClassifier);
- case (7) :
- return createMessageBeanInstance(eClassifier);
- case (4) :
- case (8) :
- return createSessionBeanInstance(eClassifier);
- default :
- return createEntityBeanInstance(eClassifier);
- }
- } else if (eClassifier.getName().equals("SecurityIdentity"))
- return createSecurityIdentitiyInstance(eClassifier);
- else if (eClassifier.getName().equals("RoleSource"))
- return createRoleSourceInstance(eClassifier);
- else if (eClassifier == EcorePackage.eINSTANCE.getEAttribute())
- return getEjbFactory().createCMPAttribute();
- return super.createInstance(ref,eObject);
- }
-
- private EObject createSecurityIdentitiyInstance(EClass eClassifier) {
- /* Alternate types */
- createdSecRoles++;
- if ((createdSecRoles & 1) == 0)
- return CommonFactory.eINSTANCE.createUseCallerIdentity();
- else
- return CommonFactory.eINSTANCE.createRunAsSpecifiedIdentity();
- }
-
- private EObject createRoleSourceInstance(EClass eClassifier) {
- return ((EjbFactory) eClassifier.getEPackage().getEFactoryInstance()).createRoleSource();
- }
-
- private EObject createMessageBeanInstance(EClass eClassifier) {
- return ((EjbFactory) eClassifier.getEPackage().getEFactoryInstance()).createMessageDriven();
- }
-
- private EObject createSessionBeanInstance(EClass eClassifier) {
- return ((EjbFactory) eClassifier.getEPackage().getEFactoryInstance()).createSession();
- }
-
- private EObject createEntityBeanInstance(EClass eClassifier) {
- return ((EjbFactory) eClassifier.getEPackage().getEFactoryInstance()).createEntity();
- }
-
- private EObject createContainerManagedEntityInstance(EClass eClassifier) {
- return EjbFactory.eINSTANCE.createContainerManagedEntity();
- }
-
- /**
- * @see org.eclipse.jst.j2ee.archive.test.GeneralEMFTest#getDepthForAttribute(EReference)
- */
- public int getDepthForAttribute(EStructuralFeature ref) {
- if (ref.getName().equals("enterpriseBeans"))
- return NUM_BEANS;
- else if (ref.getName().equals("entityBeans"))
- return NUM_BEANS;
- else if (ref.getName().equals("relationshipRoles"))
- return NUM_RELATION_ROLES;
- return super.getDepthForAttribute(ref);
- }
-
- /* (non-Javadoc)
- * @see com.ibm.etools.archive.emftest.GeneralEMFPopulationTest#populateFeatures(org.eclipse.emf.ecore.EObject)
- */
- public void populateFeatures(EObject eObject) {
- if (eObject.eClass() == EJB_PKG.getCMPAttribute()) {
- ((CMPAttribute) eObject).setName((String) EMFAttributeFeatureGenerator.createAttribute(EcorePackage.eINSTANCE.getENamedElement_Name(),eObject));
- ((CMPAttribute) eObject).setEType((EClassifier) EMFAttributeFeatureGenerator.createJavaClassProxy(EcorePackage.eINSTANCE.getETypedElement_EType(),eObject));
- } else if (eObject.eClass() == EJB_PKG.getCMRField()) {
- ((CMRField) eObject).setName((String) EMFAttributeFeatureGenerator.createAttribute(EcorePackage.eINSTANCE.getENamedElement_Name(),eObject));
- populateSharedReference(eObject, EJB_PKG.getCMRField_CollectionType());
- populateSharedReference(eObject, EJB_PKG.getCMRField_Role());
- } else
- super.populateFeatures(eObject);
- }
-
- /* (non-Javadoc)
- * @see com.ibm.etools.archive.emftest.GeneralEMFPopulationTest#populateAttributes(org.eclipse.emf.ecore.EObject)
- */
- protected void populateAttributes(EObject eObject) {
- if (eObject instanceof QueryMethodImpl) {
- List attributes = eObject.eClass().getEAllAttributes();
- for (int i = 0; i < attributes.size(); i++) {
- EAttribute att = (EAttribute) attributes.get(i);
- if (att.equals(EJB_PKG.getMethodElement_Description()) || att.equals(EJB_PKG.getMethodElement_EnterpriseBean()) || att.equals(EJB_PKG.getMethodElement_Type()) )
- continue;
- Object value = createAttributeValue(att, eObject);
- if (att.getName().equals("parms") && value == null){
- value = createAttributeValue(att, eObject);
- }
- if (att.isChangeable())
- eObject.eSet(att, value);
- }
- } else if (eObject instanceof MethodPermissionImpl) {
- List attributes = eObject.eClass().getEAllAttributes();
- for (int i = 0; i < attributes.size(); i++) {
- EAttribute att = (EAttribute) attributes.get(i);
- if(att.getName().equals("unchecked") && mpFlag){
- continue;
- }
-
- Object value = createAttributeValue(att, eObject);
- if (att.isChangeable())
- eObject.eSet(att, value);
- }
- mpFlag = !mpFlag;
- } else if (eObject instanceof EJBRelationshipRoleImpl) {
- List attributes = eObject.eClass().getEAllAttributes();
- EAttribute lastAttr = null;
- Object value = null;
- for (int i = 0; i < attributes.size(); i++) {
- EAttribute att = (EAttribute) attributes.get(i);
- if (att.getName().equals("cascadeDelete") && (lastAttr.getName().equals("multiplicity") && !value.toString().equals("Many")))
- continue;
-
- value = createAttributeValue(att, eObject);
- if (att.isChangeable())
- eObject.eSet(att, value);
- lastAttr = att;
- }
- mpFlag = !mpFlag;
- } else
- super.populateAttributes(eObject);
- }
-
-
- protected void populateSharedReference(EObject eObject, EReference ref) {
- if (ref == EJB_PKG.getCMRField_CollectionType()) {
- setReferenceValue(eObject, ref, JavaClassImpl.createClassRef("java.util.Collection"));
- return;
- } else if(eObject instanceof MethodPermission && ref.getName().equals("roles")){
- //if method permission unchecked ignore roles
- if(mpFlag){
- return;
- }
- mpFlag = !mpFlag;
- }
- super.populateSharedReference(eObject, ref);
- }
-
- /* (non-Javadoc)
- * @see com.ibm.etools.archive.emftest.GeneralEMFPopulationTest#createAttributeValue(org.eclipse.emf.ecore.EAttribute, org.eclipse.emf.ecore.EObject)
- */
- protected Object createAttributeValue(EAttribute att, EObject eObject) {
- //eat the first return type mapping because the order was changed.
- if (firstReturnTypeMapping && att.equals(EJB_PKG.getQuery_ReturnTypeMapping())){
- super.createAttributeValue(att,eObject);
- firstReturnTypeMapping = false;
- } else if (att.equals(EJB_PKG.getEnterpriseBean_Name()))
- return EMFAttributeFeatureGenerator.createAttribute(att,EJB_PKG.getEntity());
- return super.createAttributeValue(att, eObject);
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- earFile = null;
- ejbFile = null;
- mesBean = null;
- entityBean = null;
- secID = null;
- roleSource = null;
- }
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/GeneralEMFEditingTest.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/GeneralEMFEditingTest.java
deleted file mode 100644
index 36a22dbf..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/GeneralEMFEditingTest.java
+++ /dev/null
@@ -1,479 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.archive.emftests;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.LineNumberReader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.InternalEObject;
-import org.eclipse.jem.java.JavaRefPackage;
-import org.eclipse.jem.java.internal.impl.JavaClassImpl;
-import org.eclipse.jst.j2ee.archive.testutilities.EMFAttributeFeatureGenerator;
-import org.eclipse.jst.j2ee.archive.testutilities.J2EEVersionCheck;
-import org.eclipse.jst.j2ee.archive.testutilities.TestUtilities;
-import org.eclipse.jst.j2ee.common.CommonPackage;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-import org.eclipse.wst.common.internal.emf.resource.RendererFactory;
-
-
-public class GeneralEMFEditingTest extends GeneralEMFTest {
- //inner class to handle deffered shared references
- protected class DeferredSharedReferenceAction {
- EObject owner;
- EReference ref;
-
- public DeferredSharedReferenceAction(EObject owner, EReference ref) {
- this.owner = owner;
- this.ref = ref;
- }
-
- public void performAction() {
- Object value = getSharedObjectByType(owner, ref);
- setReferenceValue(owner, ref, value);
- }
- }
-
- protected Map equivalentLines;
- public List deferedReferences;
- public static int genDepth = 5;
- public static Object sharedValue;
- public int classIndex = 0;
- public static String avClass[];
- public static HashSet ignoreAtt;
-
- public int version;
- public int moduleType;
- //static versions
- public static final int VERSION_1_2 = 0;
- public static final int VERSION_1_3 = 1;
- public static final int VERSION_1_4 = 2;
-
- public static final int APPICATION = 0;
- public static final int APP_CLIENT = 1;
- public static final int CONNECTOR = 2;
- public static final int EJB = 3;
- public static final int WEB = 4;
-
- public GeneralEMFEditingTest(String name) {
- super(name);
- }
-
- public GeneralEMFEditingTest(String name, RendererFactory factory) {
- super(name, factory);
- }
-
- public void editRoot(EObject eObject) {
- editFeatures(eObject);
- //if (deferedReferences != null) {
- // for (int i = 0; i < deferedReferences.size(); i++) {
- // ((DeferredSharedReferenceAction) deferedReferences.get(i)).performAction();
- // }
- //}
- }
-
- public void editFeatures(EObject eObject) {
- if (eObject == null)
- return;
- else {
- editAttributes(eObject);
- editReferences(eObject);
- }
- }
-
- protected void editReferences(EObject eObject) {
- List references = eObject.eClass().getEAllReferences();
- for (int i = 0; i < references.size(); i++) {
- EReference ref = (EReference) references.get(i);
- if (!ref.isMany() && eObject.eGet(ref) != null)
- continue;
- if (ref.isContainment())
- populateContainmentReference(eObject, ref);
- else
- populateSharedReference(eObject, ref);
- }
- }
-
- protected void populateSharedReference(EObject eObject, EReference ref) {
- if (ref.getEType() == JavaRefPackage.eINSTANCE.getJavaClass())
- setReferenceValue(eObject, ref, createJavaClassProxy((EClass) ref.getEType()));
- else {
- EPackage pkg = ref.getEType().getEPackage();
- if (pkg == eObject.eClass().getEPackage() || pkg == CommonPackage.eINSTANCE) {
- if (eObject.eClass().getName().equals("EAnnotation") || eObject.eClass().getName().equals("EAnnotationImpl") || !J2EEVersionCheck.checkReferenceVersion(ref, version, moduleType))
- return;
- if (deferedReferences == null)
- deferedReferences = new ArrayList();
- deferedReferences.add(new DeferredSharedReferenceAction(eObject, ref));
- }
- }
- }
-
- protected void populateContainmentReference(EObject eObject, EReference ref) {
- for (int i = 0; i < getDepthForAttribute(ref); i++) {
- EObject instance = createInstance((EClass) ref.getEType());
- if (instance == null)
- return;
- if (!J2EEVersionCheck.checkReferenceVersion(ref, version, moduleType))
- continue;
- setReferenceValue(eObject, ref, instance);
- if (((InternalEObject) instance).eIsProxy())
- return;
- if (ref.getEType() == eObject.eClass())
- editAttributes(instance);
- else
- editFeatures(instance);
- }
- }
-
- protected void setReferenceValue(EObject eObject, EReference ref, Object value) {
- if (ref.getName().equals("EAnnotation") || ref.getName().equals("EAnnotationImpl") || !J2EEVersionCheck.checkReferenceVersion(ref, version, moduleType))
- return;
- if (ref.isMany()) {
- List list = (List) eObject.eGet(ref);
- if (value instanceof Collection)
- list.addAll((Collection) value);
- else
- list.add(value);
- } else {
- eObject.eSet(ref, value);
- }
- }
-
- public EObject createInstance(EClass eClassifier) {
- if (eClassifier == JavaRefPackage.eINSTANCE.getJavaClass())
- return createJavaClassProxy(eClassifier);
- return eClassifier.getEPackage().getEFactoryInstance().create(eClassifier);
- }
-
- protected void editAttributes(EObject eObject) {
- List attributes = eObject.eClass().getEAllAttributes();
- for (int i = 0; i < attributes.size(); i++) {
- EAttribute att = (EAttribute) attributes.get(i);
- if (att.isChangeable() && J2EEVersionCheck.checkAttributeVersion(att, version, moduleType)) {
- Object value = createAttributeValue(att, eObject);
- eObject.eSet(att, value);
- }
- }
- }
-
- protected Object createAttributeValue(EAttribute att, EObject eObject) {
- if (att.getEType() == JavaRefPackage.eINSTANCE.getJavaClass()) {
- return createJavaClassProxy(att.eClass()).getClass();
- }
- // if (moduleType == WEB)
- return EMFAttributeFeatureGenerator.createAttribute(att, eObject, true, version, moduleType);
- //return EMFAttributeFeatureGenerator.createAttribute(att);
- }
-
- protected EObject createJavaClassProxy(EClass metaClass) {
- if (avClass == null) {
- avClass = new String[] { "java.util.HashTable", "java.util.List", "java.sql.Data", "java.lang.Integer", "java.lang.String" };
- }
- String name = avClass[classIndex];
- classIndex++;
- if (classIndex == 5)
- classIndex = 0;
- return JavaClassImpl.createClassRef(name);
- }
-
- // Old Compare method....now using DOMComparator...remove once stable
- public void compareContents(String file1, String file2) throws Exception {
- BufferedReader reader1 = null;
- BufferedReader reader2 = null;
- try {
- int lineno = 1;
- reader1 = new BufferedReader(new InputStreamReader(getFileInputStream(file1)));
- reader2 = new BufferedReader(new InputStreamReader(getFileInputStream(file2)));
- String line1 = "", line2 = "";
- while (reader1.ready() && reader2.ready()) {
- line1 = readLineTrimComments(reader1);
- line2 = readLineTrimComments(reader2);
- if (line1 == null && line2 == null && lineno != 0)
- return;
-
- if (!line1.trim().equals(line2.trim())) {
- String message = "Error at line #: " + lineno + '\n' + line1 + '\n' + line2 + '\n';
- System.out.println(message);
- //assertTrue(message, false);
- }
- lineno++;
- }
- assertTrue("The files have a different number of lines:" + lineno + '\n' + line1 + '\n' + line2 + '\n', (!reader1.ready() && !reader2.ready()));
- } catch (IOException ex) {
- ex.printStackTrace();
- assertTrue("IO failed", false);
- } finally {
- if(reader1 != null)
- reader1.close();
- if(reader2 != null)
- reader2.close();
- }
- }
-
- /**
- * @param string
- * @return
- */
- private String readLineTrimComments(BufferedReader reader) throws IOException {
- String result = reader.readLine();
- if(result.indexOf("<!--") < 0)
- return result;
- else {
- int endCommentIndx = 0;
- while(reader.ready()) {
- if( (endCommentIndx = result.indexOf("-->")) >= 0)
- result = reader.readLine();
- else
- return result;
- }
- }
- return result;
- }
-
- public void compareContentsIgnoreWhitespace(String file1, String file2, String identifier) throws Exception {
-
- LineNumberReader reader1 = new LineNumberReader(new InputStreamReader(getFileInputStream(file1)));
- LineNumberReader reader2 = new LineNumberReader(new InputStreamReader(getFileInputStream(file2)));
- compareContentsIgnoreWhitespace(reader1, reader2, identifier);
-
- }
-
- public void compareContentsIgnoreWhitespace(LineNumberReader reader1, LineNumberReader reader2, String identifier) throws Exception {
-
- while (reader1.ready() || reader2.ready()) {
- String line1 = "", line2 = "";
- while (reader1.ready() && line1.equals("")) {
- line1 = reader1.readLine().trim();
- }
- while (reader2.ready() && line2.equals("")) {
- line2 = reader2.readLine().trim();
- }
- if (!isEquivalentLines(line1, line2)) {
- StringBuffer buff = new StringBuffer();
- buff.append("Difference found in test ");
-
- buff.append(identifier);
- buff.append("\nSource line #: ");
- buff.append(reader1.getLineNumber());
- buff.append('\n');
- buff.append(line1);
- buff.append("\nDestination line #: ");
- buff.append(reader2.getLineNumber());
- buff.append('\n');
- buff.append(line2);
- assertTrue(buff.toString(), false);
- }
- }
-
- }
-
- public boolean lineEquals(String line1, String line2) {
- return line1.equals(line2);
- }
-
- public boolean isEquivalentLines(String line1, String line2) {
- if (lineEquals(line1, line2))
- return true;
- if (equalTags(line1, line2))
- return true;
- String equiv = (String) getEquivalentLines().get(line1);
- return equiv != null && equiv.equals(line2);
- }
-
- public boolean equalTags(String line1, String line2){
- //data check, there should be no data for this test to return true
- int shortEndIndex1 = line1.indexOf("/>");
- int shortEndIndex2 = line2.indexOf("/>");
- if (shortEndIndex1 == -1 && shortEndIndex2 == -1)
- return false;
- else if (shortEndIndex1 != -1){
- String tagName1 = line1.substring(1,shortEndIndex1);
- String tagName2 = extractTagName(line2);
- if (checkNoData(line2) && tagName1.equals(tagName2)){
- return true;
- }
- }
- else if (shortEndIndex2 != -1){
- String tagName1 = extractTagName(line1);
- String tagName2 = line2.substring(1,shortEndIndex2);
- if (checkNoData(line1) && tagName1.equals(tagName2)){
- return true;
- }
- }
- return false;
- }
- /**
- * @param line2
- * @return
- */
- private String extractTagName(String line) {
- int endOpenTag = line.indexOf(">");
- return line.substring(1,endOpenTag);
- }
-
- /**
- * @param line2
- * @return
- */
- private boolean checkNoData(String line) {
- int endOpenTag = line.indexOf(">");
- int startEndTag = line.lastIndexOf("<");
- if (endOpenTag == line.length())
- return true;
- else if (endOpenTag+1 == startEndTag)
- return true;
- return false;
- }
-
- public Map getEquivalentLines() {
- if (equivalentLines == null)
- equivalentLines = new HashMap();
- return equivalentLines;
- }
-
- public void setEquivalentLines(Map equivalentLines) {
- this.equivalentLines = equivalentLines;
- }
- /*
- public void compareContents(String file1, String file2) throws Exception {
- InputStream is1, is2;
- is1 = getFileInputStream(file1);
- is2 = getFileInputStream(file2);
- InputSource input1 = new InputSource(is1);
- InputSource input2 = new InputSource(is2);
- try {
- String results;
- if(ignoreAtt == null)
- results = DomComparitor.compareDoms(input1, input2);
- else
- results = DomComparitor.compareDoms(input1, input2, ignoreAtt);
- if (results != null) {
- assertTrue("Unequal doms compared as equal " + file1 + " " + file2 + "Details: " + results, false);
- }
- } finally {
- try {
- is1.close();
- } catch (Exception e) {
- Assert.fail(e.getMessage());
- }
- try {
- is2.close();
- } catch (Exception e) {
- Assert.fail(e.getMessage());
- }
- }
- }
- */
- public InputStream getFileInputStream(String path) throws FileNotFoundException {
- return new FileInputStream(path);
- }
-
- public InputStream getResourceAsStream(String fileName) {
- InputStream in = null;
- ClassLoader loader = getClass().getClassLoader();
- if (loader == null) {
- in = ClassLoader.getSystemResourceAsStream(fileName);
- } else {
- in = loader.getResourceAsStream(fileName);
- }
- assertTrue("Unable to find resource: " + fileName, in != null);
- return in;
- }
-
- public void setGeneralDepth(int depth) {
- GeneralEMFPopulationTest.genDepth = depth;
- }
-
- public void setModuleType(int type) {
- moduleType = type;
- }
-
- public void setVersion(int version) {
- this.version = version;
- }
-
- public int getDepthForAttribute(EReference ref) {
- if (ref.isMany())
- return genDepth;
- else
- return 1;
- }
-
- public Object getSharedObjectByType(EObject owner, EReference ref) {
- sharedValue = TestUtilities.getObjectByType(owner.eResource(), ref.getEType(), ref.isMany());
- return sharedValue;
- }
-
- /**
- * @param set
- */
- public static void setIgnoreAtt(HashSet set) {
- ignoreAtt = set;
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- try {
- String out = AutomatedBVT.baseDirectory + "testOutput/";
- File del = new File(out);
- deleteDirectory(del);
- del.delete();
- out = AutomatedBVT.baseDirectory + "../testData/testOutput/";
- del = new File(out);
- deleteDirectory(del);
- del.delete();
- }
- catch (Exception e){
- e.printStackTrace();
- }
- super.tearDown();
- }
-
- protected void deleteDirectory(File directory)
- throws IOException
- {
- if (directory.exists()){
- File[] delFiles = directory.listFiles();
-
- for(int i=0; i<delFiles.length; ++i)
- {
- if(delFiles[i].isDirectory())
- deleteDirectory(delFiles[i]);
- delFiles[i].delete();
- }
- }
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- //TODO: Remove this line after ws xsd's are restored.
- RendererFactory.getDefaultRendererFactory().setValidating(false);
- }
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/GeneralEMFPopulationTest.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/GeneralEMFPopulationTest.java
deleted file mode 100644
index 8d0594b8..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/GeneralEMFPopulationTest.java
+++ /dev/null
@@ -1,490 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.archive.emftests;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.LineNumberReader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.InternalEObject;
-import org.eclipse.emf.ecore.util.BasicFeatureMap;
-import org.eclipse.emf.ecore.util.FeatureMapUtil;
-import org.eclipse.jem.java.JavaRefPackage;
-import org.eclipse.jst.j2ee.archive.testutilities.EAttributeDescriptor;
-import org.eclipse.jst.j2ee.archive.testutilities.EMFAttributeFeatureGenerator;
-import org.eclipse.jst.j2ee.archive.testutilities.J2EEVersionCheck;
-import org.eclipse.jst.j2ee.archive.testutilities.TestUtilities;
-import org.eclipse.jst.j2ee.common.CommonPackage;
-import org.eclipse.jst.j2ee.common.EJBLocalRef;
-import org.eclipse.jst.j2ee.common.QName;
-import org.eclipse.jst.j2ee.common.ResAuthTypeBase;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-import org.eclipse.jst.j2ee.ejb.EjbPackage;
-import org.eclipse.jst.j2ee.ejb.MessageDriven;
-import org.eclipse.jst.j2ee.ejb.MethodElementKind;
-import org.eclipse.wst.common.internal.emf.resource.RendererFactory;
-
-
-public class GeneralEMFPopulationTest extends GeneralEMFTest {
- //inner class to handle deffered shared references
- protected class DeferredSharedReferenceAction {
- EObject owner;
- EReference ref;
-
- public DeferredSharedReferenceAction(EObject owner, EReference ref) {
- this.owner = owner;
- this.ref = ref;
- }
-
- public void performAction() {
- Object value = getSharedObjectByType(owner, ref);
- setReferenceValue(owner, ref, value);
- }
- }
-
- protected Map equivalentLines;
- public List deferedReferences;
- public static int genDepth = 5;
- public static Object sharedValue;
- public static HashSet ignoreAtt;
-
- public int version;
- public int moduleType;
- //static versions
- public static final int VERSION_1_2 = 0;
- public static final int VERSION_1_3 = 1;
- public static final int VERSION_1_4 = 2;
- public static final int VERSION_5_0 = 3;
-
- public static final int APPLICATION = 0;
- public static final int APP_CLIENT = 1;
- public static final int CONNECTOR = 2;
- public static final int EJB = 3;
- public static final int WEB = 4;
-
- public GeneralEMFPopulationTest(String name) {
- super(name);
- }
-
- public GeneralEMFPopulationTest(String name, RendererFactory factory) {
- super(name, factory);
- }
-
- public void populateRoot(EObject eObject) {
- populateFeatures(eObject);
- if (deferedReferences != null) {
- for (int i = 0; i < deferedReferences.size(); i++) {
- ((DeferredSharedReferenceAction) deferedReferences.get(i)).performAction();
- }
- }
- }
-
- public void populateFeatures(EObject eObject) {
- if (eObject == null)
- return;
- else {
- populateAttributes(eObject);
- populateReferences(eObject);
- }
- }
-
- protected void populateReferences(EObject eObject) {
- List references = eObject.eClass().getEAllReferences();
- for (int i = 0; i < references.size(); i++) {
- EReference ref = (EReference) references.get(i);
- if (!ref.isMany() && eObject.eGet(ref) != null)
- continue;
- if (eObject instanceof MessageDriven && (ref.equals(EjbPackage.eINSTANCE.getEnterpriseBean_HomeInterface()) || ref.equals(EjbPackage.eINSTANCE.getEnterpriseBean_RemoteInterface()) || ref.equals(EjbPackage.eINSTANCE.getEnterpriseBean_LocalInterface()) || ref.equals(EjbPackage.eINSTANCE.getEnterpriseBean_LocalHomeInterface()) || ref.equals(EjbPackage.eINSTANCE.getEnterpriseBean_SecurityRoleRefs())))
- continue;
- if (ref.isContainment())
- populateContainmentReference(eObject, ref);
- else
- populateSharedReference(eObject, ref);
- }
- }
-
- protected void populateSharedReference(EObject eObject, EReference ref) {
- if (ref.getEType() == JavaRefPackage.eINSTANCE.getJavaClass())
- setReferenceValue(eObject, ref, EMFAttributeFeatureGenerator.createJavaClassProxy(ref,eObject));
- else {
- EPackage pkg = ref.getEType().getEPackage();
- //if (pkg == eObject.eClass().getEPackage() || pkg == CommonPackage.eINSTANCE) {
- if (eObject.eClass().getName().equals("EAnnotation") || eObject.eClass().getName().equals("EAnnotationImpl") || !J2EEVersionCheck.checkReferenceVersion(ref, version, moduleType))
- return;
- if (deferedReferences == null)
- deferedReferences = new ArrayList();
- deferedReferences.add(new DeferredSharedReferenceAction(eObject, ref));
- //}
- }
- }
-
- protected void populateContainmentReference(EObject eObject, EReference ref) {
- for (int i = 0; i < getDepthForAttribute(ref); i++) {
- EObject instance = createInstance(ref,eObject);
- if (instance == null)
- return;
- if (!J2EEVersionCheck.checkReferenceVersion(ref, version, moduleType))
- continue;
- setReferenceValue(eObject, ref, instance);
- if (((InternalEObject) instance).eIsProxy())
- return;
- if (ref.getEType() == eObject.eClass())
- populateAttributes(instance);
- else
- populateFeatures(instance);
- }
- }
-
- protected void setReferenceValue(EObject eObject, EStructuralFeature ref, Object value) {
- if (ref.getName().equals("EAnnotation") || ref.getName().equals("EAnnotationImpl") || !J2EEVersionCheck.checkReferenceVersion(ref, version, moduleType))
- return;
- if (ref.isMany()) {
- List list = (List) eObject.eGet(ref);
- if (list instanceof BasicFeatureMap) {
- BasicFeatureMap aMap = (BasicFeatureMap)list;
- if (value instanceof Collection) {
- for (Iterator iterator = ((Collection)value).iterator(); iterator.hasNext();) {
- Object obj = iterator.next();
- aMap.add(FeatureMapUtil.createEntry(ref, obj));
- }
- } else aMap.add(FeatureMapUtil.createEntry(ref, value));
-
- } else {
- if (value instanceof Collection)
- list.addAll((Collection) value);
-
- else
- list.add(value);
- }
- } else {
- eObject.eSet(ref, value);
- }
- }
-
- public EObject createInstance(EReference ref, EObject eObject) {
- if (ref.getEType() == JavaRefPackage.eINSTANCE.getJavaClass())
- return EMFAttributeFeatureGenerator.createJavaClassProxy(ref, eObject);
- return ref.getEType().getEPackage().getEFactoryInstance().create((EClass)ref.getEType());
- }
-
- protected void populateAttributes(EObject eObject) {
- if (eObject.eClass() == CommonPackage.eINSTANCE.getQName()) {
- populateAttributesQName(eObject);
- return;
- }
- List attributes = eObject.eClass().getEAllAttributes();
- for (int i = 0; i < attributes.size(); i++) {
- EAttribute att = (EAttribute) attributes.get(i);
- if (eObject instanceof EJBLocalRef && (att.equals(CommonPackage.eINSTANCE.getEjbRef_Home()) || att.equals(CommonPackage.eINSTANCE.getEjbRef_Remote())))
- continue;
- EAttributeDescriptor desc = new EAttributeDescriptor(att,eObject.eClass());
- if (desc.getFeature().getName().equals("group")) continue;
- primPopulateAttrbute(eObject, att);
- }
- }
-
- protected void primPopulateAttrbute(EObject eObject, EAttribute att) {
- if (att.isChangeable() && J2EEVersionCheck.checkAttributeVersion(att, version, moduleType)) {
- for (int j = 0 ; j < getDepthForAttribute(att);j++){
- Object value = createAttributeValue(att, eObject);
- setReferenceValue(eObject,att,value);
- }
- }
- }
-
-
-
- /**
- * @param eObject
- */
- protected void populateAttributesQName(EObject eObject) {
- String prefix = (String)createAttributeValue(CommonPackage.eINSTANCE.getQName_InternalPrefixOrNsURI(), eObject);
- String localPart = (String)createAttributeValue(CommonPackage.eINSTANCE.getQName_LocalPart(), eObject);
- ((QName)eObject).setValues(prefix, "http://www.ibm.com", localPart);
- }
-
- protected Object createAttributeValue(EAttribute att, EObject eObject) {
- if (att.getEType() == JavaRefPackage.eINSTANCE.getJavaClass()) {
- return EMFAttributeFeatureGenerator.createJavaClassProxy(att,eObject).getClass();
- } else if (att == CommonPackage.eINSTANCE.getResourceRef_Auth())
- return createResAuth(att, eObject);
- else if (att == EjbPackage.eINSTANCE.getMethodElement_Type())
- return createMethodElementType(att, eObject);
- else
- return primCreateAttributeValue(att, eObject);
- //return EMFAttributeFeatureGenerator.createAttribute(att);
- }
-
- protected Object primCreateAttributeValue(EAttribute att, EObject eObject) {
- return EMFAttributeFeatureGenerator.createAttribute(att, eObject, true, version, moduleType);
- }
-
- // Old Compare method....now using DOMComparator...remove once stable
- public void compareContents(String file1, String file2) throws Exception {
- try {
- int lineno = 1;
- BufferedReader reader1 = new BufferedReader(new InputStreamReader(getFileInputStream(file1)));
- BufferedReader reader2 = new BufferedReader(new InputStreamReader(getFileInputStream(file2)));
- String line1 = "", line2 = "";
- while (reader1.ready() && reader2.ready()) {
- line1 = reader1.readLine();
- line2 = reader2.readLine();
- if (line1 == null && line2 == null && lineno != 0)
- return;
- if (!line1.equals(line2)) {
- String message = "Error at line #: " + lineno + '\n' + line1 + '\n' + line2 + '\n';
- assertTrue(message, false);
- break; // added to escape compare
- }
- lineno++;
- }
- assertTrue("The files have a different number of lines:" + lineno + '\n' + line1 + '\n' + line2 + '\n', (!reader1.ready() && !reader2.ready()));
- } catch (IOException ex) {
- assertTrue("IO failed", false);
- }
- }
- public void compareContentsIgnoreWhitespace(String file1, String file2, String identifier) throws Exception {
-
- LineNumberReader reader1 = new LineNumberReader(new InputStreamReader(getFileInputStream(file1)));
- LineNumberReader reader2 = new LineNumberReader(new InputStreamReader(getFileInputStream(file2)));
- compareContentsIgnoreWhitespace(reader1, reader2, identifier);
-
- }
-
- public void compareContentsIgnoreWhitespace(LineNumberReader reader1, LineNumberReader reader2, String identifier) throws Exception {
- List errors = new ArrayList();
- String msg = null;
- while (reader1.ready() || reader2.ready()) {
- String line1 = "", line2 = "";
- while (reader1.ready() && line1 != null && line1.equals("")) {
- line1 = reader1.readLine();
- if (line1 != null)
- line1 = line1.trim();
- }
- while (reader2.ready() && line2 != null && line2.equals("")) {
- line2 = reader2.readLine();
- if (line2 != null)
- line2 = line2.trim();
- }
- if (line1 != null && line2 != null && !isEquivalentLines(line1, line2)) {
- StringBuffer buff = new StringBuffer();
- buff.append("------------------------------ ");
- buff.append("\nSource line #: ");
- buff.append(reader1.getLineNumber());
- buff.append('\n');
- buff.append(line1);
- buff.append("\nDestination line #: ");
- buff.append(reader2.getLineNumber());
- buff.append('\n');
- buff.append(line2);
- System.out.println(buff.toString());
- errors.add(buff);
- break;
- }
- }
- if (!errors.isEmpty())
- assertTrue("Errors Found, Check Console.", false);
- }
-
- public boolean lineEquals(String line1, String line2) {
- return line1 != null && line1.equals(line2);
- }
-
- public boolean isEquivalentLines(String line1, String line2) {
- if (lineEquals(line1, line2))
- return true;
-
- String equiv = (String) getEquivalentLines().get(line1);
- if (equiv == null){
- equiv = (String)getEquivalentLines().get(line2);
- if (equiv != null)
- return equiv.equals(line1);
- }
- return equiv != null && equiv.equals(line2);
- }
- public Map getEquivalentLines() {
- if (equivalentLines == null)
- equivalentLines = new HashMap();
- return equivalentLines;
- }
-
- public void setEquivalentLines(Map equivalentLines) {
- this.equivalentLines = equivalentLines;
- }
- /*
- public void compareContents(String file1, String file2) throws Exception {
- InputStream is1, is2;
- is1 = getFileInputStream(file1);
- is2 = getFileInputStream(file2);
- InputSource input1 = new InputSource(is1);
- InputSource input2 = new InputSource(is2);
- try {
- String results;
- if(ignoreAtt == null)
- results = DomComparitor.compareDoms(input1, input2);
- else
- results = DomComparitor.compareDoms(input1, input2, ignoreAtt);
- if (results != null) {
- assertTrue("Unequal doms compared as equal " + file1 + " " + file2 + "Details: " + results, false);
- }
- } finally {
- try {
- is1.close();
- } catch (Exception e) {
- Assert.fail(e.getMessage());
- }
- try {
- is2.close();
- } catch (Exception e) {
- Assert.fail(e.getMessage());
- }
- }
- }
- */
- public InputStream getFileInputStream(String path) throws FileNotFoundException {
- return new FileInputStream(path);
- }
-
- public InputStream getResourceAsStream(String fileName) {
- InputStream in = null;
- ClassLoader loader = getClass().getClassLoader();
- if (loader == null) {
- in = ClassLoader.getSystemResourceAsStream(fileName);
- } else {
- in = loader.getResourceAsStream(fileName);
- }
- assertTrue("Unable to find resource: " + fileName, in != null);
- return in;
- }
-
- public void setGeneralDepth(int depth) {
- GeneralEMFPopulationTest.genDepth = depth;
- }
-
- public void setModuleType(int type) {
- moduleType = type;
- }
-
- public void setVersion(int version) {
- this.version = version;
- }
-
- public int getDepthForAttribute(EStructuralFeature feature) {
- if (feature.isMany())
- return genDepth;
- else
- return 1;
- }
-
- public Object getSharedObjectByType(EObject owner, EReference ref) {
- sharedValue = TestUtilities.getObjectByType(owner.eResource(), ref.getEType(), ref.isMany());
- return sharedValue;
- }
-
- /**
- * @param set
- */
- public static void setIgnoreAtt(HashSet set) {
- ignoreAtt = set;
- }
-
-
-
- protected Object createResAuth(EAttribute att, EObject eObject) {
- Object auth = null;
- do {
- auth = primCreateAttributeValue(att, eObject);
- } while (!isValidAuth((ResAuthTypeBase)auth));
- return auth;
- }
-
- /**
- * Web will need to override for J2EE 1.2/1/3
- * @param auth
- * @return
- */
- protected boolean isValidAuth(ResAuthTypeBase auth) {
- return auth == ResAuthTypeBase.APPLICATION_LITERAL || auth == ResAuthTypeBase.CONTAINER_LITERAL;
- }
-
- protected Object createMethodElementType(EAttribute att, EObject eObject) {
- Object type = null;
- do {
- type = primCreateAttributeValue(att, eObject);
- } while (!isValidMethodElementType((MethodElementKind)type));
- return type;
- }
-
- /**
- * Web will need to override for J2EE 1.2/1/3
- * @param auth
- * @return
- */
- protected boolean isValidMethodElementType(MethodElementKind type) {
- if (version == VERSION_1_4)
- return true;
- return version != VERSION_1_4 && type != MethodElementKind.SERVICE_ENDPOINT_LITERAL;
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- try {
- String out = AutomatedBVT.baseDirectory + "testOutput/";
- File del = new File(out);
- deleteDirectory(del);
- del.delete();
- out = AutomatedBVT.baseDirectory + "../testData/testOutput/";
- del = new File(out);
- deleteDirectory(del);
- del.delete();
- }
- catch (Exception e){
- e.printStackTrace();
- }
- super.tearDown();
- }
-
- protected void deleteDirectory(File directory)
- throws IOException
- {
- if (directory.exists()){
- File[] delFiles = directory.listFiles();
-
- for(int i=0; i<delFiles.length; ++i)
- {
- if(delFiles[i].isDirectory())
- deleteDirectory(delFiles[i]);
- delFiles[i].delete();
- }
- }
- }
-
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/GeneralEMFTest.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/GeneralEMFTest.java
deleted file mode 100644
index d349972e..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/GeneralEMFTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- *
- */
-package org.eclipse.jst.j2ee.archive.emftests;
-
-import java.util.HashSet;
-
-import org.eclipse.jst.j2ee.application.ApplicationFactory;
-import org.eclipse.jst.j2ee.application.ApplicationPackage;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchiveFactory;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchivePackage;
-import org.eclipse.jst.j2ee.ejb.EjbFactory;
-import org.eclipse.jst.j2ee.ejb.EjbPackage;
-import org.eclipse.jst.j2ee.webapplication.WebapplicationFactory;
-import org.eclipse.jst.j2ee.webapplication.WebapplicationPackage;
-import org.eclipse.wst.common.internal.emf.resource.RendererFactory;
-import org.eclipse.wst.common.tests.BaseTestCase;
-
-/**
- * @author itewk
- *
- */
-public abstract class GeneralEMFTest extends BaseTestCase {
- private RendererFactory testingFactory;
- private RendererFactory defaultFactory;
-
- public GeneralEMFTest(String name) {
- super(name);
-
- defaultFactory = RendererFactory.getDefaultRendererFactory();
- testingFactory = RendererFactory.getDefaultRendererFactory();
- }
-
- public GeneralEMFTest(String name, RendererFactory factory) {
- super(name);
-
- defaultFactory = RendererFactory.getDefaultRendererFactory();
- testingFactory = factory;
- }
-
- protected void setUp() throws Exception {
- //set the default factory to the factory needed for this test run
- RendererFactory.setDefaultRendererFactory(testingFactory);
-
- super.setUp();
- }
-
- protected void tearDown() throws Exception {
- //set the default factory back to the orginal default
- RendererFactory.setDefaultRendererFactory(defaultFactory);
-
- super.setUp();
- }
-
- protected CommonarchiveFactory getArchiveFactory() {
- return CommonarchivePackage.eINSTANCE.getCommonarchiveFactory();
- }
-
- protected EjbFactory getEjbFactory() {
- return EjbPackage.eINSTANCE.getEjbFactory();
- }
-
- protected ApplicationFactory getApplicationFactory() {
- return ApplicationPackage.eINSTANCE.getApplicationFactory();
- }
-
- protected WebapplicationFactory getWebAppFactory() {
- return WebapplicationPackage.eINSTANCE.getWebapplicationFactory();
- }
-
- protected HashSet ignorableAttributes(){
- HashSet set = new HashSet();
- set.add("id");
- return set;
- }
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/RarEMFEditTest.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/RarEMFEditTest.java
deleted file mode 100644
index fb4463eb..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/RarEMFEditTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package org.eclipse.jst.j2ee.archive.emftests;
-
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.RARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.DuplicateObjectException;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-import org.eclipse.jst.j2ee.jca.ConnectorResource;
-import org.eclipse.wst.common.internal.emf.resource.RendererFactory;
-
-
-public class RarEMFEditTest extends GeneralEMFEditingTest {
- RARFile rarFile;
-
- public RarEMFEditTest(String name) {
- super(name);
- }
-
- public RarEMFEditTest(String name, RendererFactory factory) {
- super(name, factory);
- }
-
- public static void main(java.lang.String[] args) {
- String[] className = { "com.ibm.etools.archive.test.RarEMFEditTest", "-noloading" };
- TestRunner.main(className);
- }
-
- public static junit.framework.Test suite(RendererFactory factory) {
- TestSuite suite = new TestSuite(RarEMFEditTest.class.getName());
- suite.addTest(new RarEMFEditTest("testRAREdit",factory));
- return suite;
- }
-
- public void testRAREdit() throws Exception {
- getRar();
- assertEquals("1.0", rarFile.getDeploymentDescriptor().getSpecVersion());
-
- ConnectorResource DD = (ConnectorResource) rarFile.getDeploymentDescriptorResource();
- setVersion(VERSION_1_3);
- setModuleType(CONNECTOR);
- editRoot(DD.getRootObject());
- String curDir = AutomatedBVT.baseDirectory;
-
- String out = curDir + "testOutput/EMFModelCreationTests/EditRarEAR";
- rarFile.extractTo(out, Archive.EXPAND_ALL);
- rarFile.close();
-
- //Compare work in progress
-
- String exampleDeploymentDesURI = curDir + "EMFTests/ra.xml";
- String curDeploymentDesURI = curDir + out + "/fooRAR/META-INF/ra.xml";
- //compareContents(curDeploymentDesURI, exampleDeploymentDesURI);
- }
-
- public void getRar() throws DuplicateObjectException, OpenFailureException {
- String in = AutomatedBVT.baseDirectory + "loose_module_workspace/LooseConnector/fooRAR/";
- rarFile = getArchiveFactory().openRARFile(in);
- assertTrue(rarFile.getDeploymentDescriptor() != null);
- }
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/RarEMFTest.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/RarEMFTest.java
deleted file mode 100644
index f64e74bc..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/RarEMFTest.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.archive.emftests;
-
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.jst.j2ee.archive.testutilities.EMFAttributeFeatureGenerator;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.RARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.DuplicateObjectException;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
-import org.eclipse.jst.j2ee.jca.ConnectorResource;
-import org.eclipse.jst.j2ee.jca.JcaPackage;
-import org.eclipse.wst.common.internal.emf.resource.RendererFactory;
-
-
-public class RarEMFTest extends GeneralEMFPopulationTest {
- EARFile earFile;
- protected RARFile rarFile;
-
- public RarEMFTest(String name) {
- super(name);
- }
-
- public RarEMFTest(String name, RendererFactory factory) {
- super(name, factory);
- }
-
- public static void main(java.lang.String[] args) {
- String[] className = { "com.ibm.etools.archive.test.RarEMFTest", "-noloading" };
- TestRunner.main(className);
- }
-
- public static junit.framework.Test suite(RendererFactory factory) {
- TestSuite suite = new TestSuite(RarEMFTest.class.getName());
- //[248158] suite.addTest(new RarEMFTest("testRARPopulation",factory));
- suite.addTest(new RarEMFTest("test14RARPopulation",factory));
- return suite;
- }
-
- public void testRARPopulation() throws Exception {
- EMFAttributeFeatureGenerator.reset();
- createEAR();
- createRAR();
-
- ConnectorResource DD = (ConnectorResource) rarFile.getDeploymentDescriptorResource();
- //TODO: individual test for each version
- DD.setVersionID(J2EEVersionConstants.J2EE_1_3_ID);
- setVersion(VERSION_1_3);
- setModuleType(CONNECTOR);
- populateRoot(DD.getRootObject());
-
- String out = AutomatedBVT.baseDirectory + "testOutput/TestRarEAR";
- earFile.extractTo(out, Archive.EXPAND_ALL);
- earFile.close();
-
- //Compare work in progress
- String curDir = AutomatedBVT.baseDirectory;
- String exampleDeploymentDesURI = curDir + "EMFTestNoID/ra.xml";
- String curDeploymentDesURI = curDir + "testOutput/TestRarEAR/fooRAR/META-INF/ra.xml";
- setIgnoreAtt(ignorableAttributes());
- compareContentsIgnoreWhitespace(curDeploymentDesURI, exampleDeploymentDesURI, null);
- }
- public void test14RARPopulation() throws Exception {
- EMFAttributeFeatureGenerator.reset();
- createEAR();
- createRAR();
-
- ConnectorResource DD = (ConnectorResource) rarFile.getDeploymentDescriptorResource();
- //TODO: individual test for each version
- DD.setVersionID(J2EEVersionConstants.J2EE_1_4_ID);
- setVersion(VERSION_1_4);
- setModuleType(CONNECTOR);
- populateRoot(DD.getRootObject());
-
- String out = AutomatedBVT.baseDirectory + "testOutput/Test14RarEAR";
- earFile.extractTo(out, Archive.EXPAND_ALL);
- earFile.close();
-
- getRar();
- assertTrue("1.5".equals(rarFile.getDeploymentDescriptor().getSpecVersion()));
- out = AutomatedBVT.baseDirectory + "testOutput/Test14RarEAR2";
- rarFile.extractTo(out, Archive.EXPAND_ALL);
- rarFile.close();
-
- //Compare work in progress
- String curDir = AutomatedBVT.baseDirectory;
- String exampleDeploymentDesURI = curDir + "testOutput/Test14RarEAR2/META-INF/ra.xml";
- String curDeploymentDesURI = curDir + "testOutput/Test14RarEAR/fooRAR/META-INF/ra.xml";
- setIgnoreAtt(ignorableAttributes());
- compareContentsIgnoreWhitespace(curDeploymentDesURI, exampleDeploymentDesURI, null);
- }
-
- public void getRar() throws DuplicateObjectException, OpenFailureException {
- String in = AutomatedBVT.baseDirectory + "testOutput/Test14RarEAR/fooRAR";
- rarFile = getArchiveFactory().openRARFile(in);
- assertTrue(rarFile.getDeploymentDescriptor() != null);
- }
-
- public void createRAR() throws DuplicateObjectException {
- rarFile = getArchiveFactory().createRARFileInitialized("fooRAR");
- rarFile = (RARFile) earFile.addCopy(rarFile);
- rarFile.getDeploymentDescriptor().setDisplayName("fooRAR");
- assertTrue(rarFile.getDeploymentDescriptor() != null);
- }
-
- public void createEAR() {
- String earName = "Test.ear";
- earFile = getArchiveFactory().createEARFileInitialized(earName);
- assertTrue(earFile.getDeploymentDescriptor() != null);
- }
-
- /* (non-Javadoc)
- * @see com.ibm.etools.archive.emftest.GeneralEMFPopulationTest#createAttributeValue(org.eclipse.emf.ecore.EAttribute)
- */
- protected Object createAttributeValue(EAttribute att, EObject eObject) {
- //TODO: delete this after the model is fixed
- if (att == JcaPackage.eINSTANCE.getConfigProperty_Type())
- return "java.lang.String";
- else if (att == JcaPackage.eINSTANCE.getAuthenticationMechanism_CredentialInterface())
- return "javax.resource.spi.security.PasswordCredential";
- else if (att == JcaPackage.eINSTANCE.getConnector_SpecVersion() && version == VERSION_1_3)
- return "1.0";
- else
- return super.createAttributeValue(att, eObject);
- }
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/ResolverTest.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/ResolverTest.java
deleted file mode 100644
index 87b059ed..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/ResolverTest.java
+++ /dev/null
@@ -1,264 +0,0 @@
-package org.eclipse.jst.j2ee.archive.emftests;
-
-import java.util.List;
-
-import junit.framework.TestSuite;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.jst.j2ee.archive.testutilities.EMFAttributeFeatureGenerator;
-import org.eclipse.jst.j2ee.common.CommonFactory;
-import org.eclipse.jst.j2ee.common.SecurityIdentity;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EJBJarFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.DuplicateObjectException;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-import org.eclipse.jst.j2ee.ejb.CMPAttribute;
-import org.eclipse.jst.j2ee.ejb.EJBResource;
-import org.eclipse.jst.j2ee.ejb.EjbFactory;
-import org.eclipse.jst.j2ee.ejb.EjbPackage;
-import org.eclipse.jst.j2ee.ejb.RoleSource;
-import org.eclipse.jst.j2ee.ejb.internal.impl.MethodPermissionImpl;
-import org.eclipse.jst.j2ee.ejb.internal.impl.QueryMethodImpl;
-import org.eclipse.wst.common.internal.emf.resource.RendererFactory;
-
-
-public class ResolverTest extends GeneralEMFEditingTest {
-
- protected static final String _META_INF_EJB_JAR_XML = "/META-INF/ejb-jar.xml";
-
- protected static final EjbPackage EJB_PKG = EjbPackage.eINSTANCE;
-
- EARFile earFile;
-
- EJBJarFile ejbFile;
-
- EObject mesBean, entityBean;
-
- SecurityIdentity secID;
-
- RoleSource roleSource;
-
- int NUM_BEANS = 10;
-
- final int NUM_RELATION_ROLES = 2;
-
- int createdBeans = 0;
-
- int createdSecRoles = 0;
-
- protected int createdSecurityIdentities = 0;
-
- boolean mpFlag = false;
-
- public ResolverTest(String name) {
- super(name);
- }
-
- public ResolverTest(String name, RendererFactory factory) {
- super(name, factory);
- }
-
- public static void main(java.lang.String[] args) {
- junit.textui.TestRunner.main(new String[] { ResolverTest.class.getName()});
- }
-
- public static junit.framework.Test suite(RendererFactory factory) {
- TestSuite suite = new TestSuite(ResolverTest.class.getName());
- suite.addTest(new ResolverTest("testResolver",factory));
- suite.addTest(new ResolverTest("testResolverNoSchemaLocation",factory));
- return suite;
- }
-
- public void testResolver() throws Exception {
- String in = AutomatedBVT.baseDirectory + "../testData/sl";
- getEJB(in);
-
- assertEquals("2.1", ejbFile.getDeploymentDescriptor().getVersion());
- EJBResource DD = (EJBResource) ejbFile.getDeploymentDescriptorResource();
- setVersion(VERSION_1_4);
- setModuleType(EJB);
-
- String out = AutomatedBVT.baseDirectory + "../testData/testOutput/sl";
- ejbFile.extractTo(out, Archive.EXPAND_ALL);
- ejbFile.close();
-
- String exampleDeploymentDesURI = in + _META_INF_EJB_JAR_XML;
- String curDeploymentDesURI = out + _META_INF_EJB_JAR_XML;
- compareContents(curDeploymentDesURI, exampleDeploymentDesURI);
- }
-
- public void testResolverNoSchemaLocation() throws Exception {
-
- boolean validating = RendererFactory.getDefaultRendererFactory().isValidating();
- try {
- RendererFactory.getDefaultRendererFactory().setValidating(false);
-
- String in = AutomatedBVT.baseDirectory + "../testData/no-sl";
- getEJB(in);
-
- assertEquals("2.1", ejbFile.getDeploymentDescriptor().getVersion());
- EJBResource DD = (EJBResource) ejbFile.getDeploymentDescriptorResource();
- setVersion(VERSION_1_4);
- setModuleType(EJB);
-
- String out = AutomatedBVT.baseDirectory + "../testData/testOutput/no-sl";
- ejbFile.extractTo(out, Archive.EXPAND_ALL);
- ejbFile.close();
-
- String exampleDeploymentDesURI = in + _META_INF_EJB_JAR_XML;
- String curDeploymentDesURI = out + _META_INF_EJB_JAR_XML;
- compareContents(curDeploymentDesURI, exampleDeploymentDesURI);
- } catch (RuntimeException re) {
- re.printStackTrace();
- } finally {
- RendererFactory.getDefaultRendererFactory().setValidating(validating);
- }
- }
-
- public void getEJB(String in) throws DuplicateObjectException, OpenFailureException {
- ejbFile = getArchiveFactory().openEJBJarFile(in);
- assertTrue(ejbFile.getDeploymentDescriptor() != null);
- }
-
- public EObject createInstance(EClass eClassifier) {
- if (eClassifier.getName().equals("EnterpriseBean")) {
- createdBeans++;
- switch (createdBeans) {
- case (3):
- return createContainerManagedEntityInstance(eClassifier);
- case (7):
- return createMessageBeanInstance(eClassifier);
- case (4):
- case (8):
- return createSessionBeanInstance(eClassifier);
- default:
- return createEntityBeanInstance(eClassifier);
- }
- } else if (eClassifier.getName().equals("SecurityIdentity"))
- return createSecurityIdentitiyInstance(eClassifier);
- else if (eClassifier.getName().equals("RoleSource"))
- return createRoleSourceInstance(eClassifier);
- else if (eClassifier == EcorePackage.eINSTANCE.getEAttribute()) return getEjbFactory().createCMPAttribute();
- return super.createInstance(eClassifier);
- }
-
- private EObject createSecurityIdentitiyInstance(EClass eClassifier) {
- /* Alternate types */
- createdSecRoles++;
- if ((createdSecRoles & 1) == 0)
- return CommonFactory.eINSTANCE.createUseCallerIdentity();
- else
- return CommonFactory.eINSTANCE.createRunAsSpecifiedIdentity();
- }
-
- private EObject createRoleSourceInstance(EClass eClassifier) {
- return ((EjbFactory) eClassifier.getEPackage().getEFactoryInstance()).createRoleSource();
- }
-
- private EObject createMessageBeanInstance(EClass eClassifier) {
- return ((EjbFactory) eClassifier.getEPackage().getEFactoryInstance()).createMessageDriven();
- }
-
- private EObject createSessionBeanInstance(EClass eClassifier) {
- return ((EjbFactory) eClassifier.getEPackage().getEFactoryInstance()).createSession();
- }
-
- private EObject createEntityBeanInstance(EClass eClassifier) {
- return ((EjbFactory) eClassifier.getEPackage().getEFactoryInstance()).createEntity();
- }
-
- private EObject createContainerManagedEntityInstance(EClass eClassifier) {
- return EjbFactory.eINSTANCE.createContainerManagedEntity();
- }
-
- /**
- * @see org.eclipse.jst.j2ee.archive.test.GeneralEMFTest#getDepthForAttribute(EReference)
- */
- public int getDepthForAttribute(EReference ref) {
- if (ref.getName().equals("enterpriseBeans"))
- return NUM_BEANS;
- else if (ref.getName().equals("entityBeans"))
- return NUM_BEANS;
- else if (ref.getName().equals("relationshipRoles")) return NUM_RELATION_ROLES;
- return super.getDepthForAttribute(ref);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.archive.emftest.GeneralEMFPopulationTest#populateFeatures(org.eclipse.emf.ecore.EObject)
- */
- public void populateFeatures(EObject eObject) {
- if (eObject.eClass() == EJB_PKG.getCMPAttribute()) {
- ((CMPAttribute) eObject).setName((String) EMFAttributeFeatureGenerator.createAttribute(
- EcorePackage.eINSTANCE.getENamedElement_Name(), eObject));
- ((CMPAttribute) eObject).setEType((EClassifier) createJavaClassProxy(null));
- } else
- super.editFeatures(eObject);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.archive.emftest.GeneralEMFPopulationTest#populateAttributes(org.eclipse.emf.ecore.EObject)
- */
- protected void populateAttributes(EObject eObject) {
- if (eObject instanceof QueryMethodImpl) {
- List attributes = eObject.eClass().getEAllAttributes();
- for (int i = 0; i < attributes.size(); i++) {
- EAttribute att = (EAttribute) attributes.get(i);
- Object value = createAttributeValue(att, eObject);
- if (att.getName().equals("parms") && value == null) {
- value = createAttributeValue(att, eObject);
- }
- if (att.isChangeable()) eObject.eSet(att, value);
- }
- } else if (eObject instanceof MethodPermissionImpl) {
- List attributes = eObject.eClass().getEAllAttributes();
- for (int i = 0; i < attributes.size(); i++) {
- EAttribute att = (EAttribute) attributes.get(i);
- if (att.getName().equals("unchecked") && mpFlag) {
- continue;
- }
-
- Object value = createAttributeValue(att, eObject);
- if (att.isChangeable()) eObject.eSet(att, value);
- }
- mpFlag = !mpFlag;
- } else
- super.editAttributes(eObject);
- }
-
- protected void populateSharedReference(EObject eObject, EReference ref) {
- if (eObject instanceof MethodPermissionImpl && ref.getName().equals("roles")) {
- mpFlag = !mpFlag;
- //if method permission unchecked ignore roles
- if (!mpFlag) { return; }
- }
- super.populateSharedReference(eObject, ref);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- earFile = null;
- ejbFile = null;
- mesBean = null;
- entityBean = null;
- secID = null;
- roleSource = null;
-
- super.tearDown();
- }
-
-} \ No newline at end of file
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/WarEMFEditTest.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/WarEMFEditTest.java
deleted file mode 100644
index 6c2c9354..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/WarEMFEditTest.java
+++ /dev/null
@@ -1,139 +0,0 @@
-package org.eclipse.jst.j2ee.archive.emftests;
-
-import java.util.List;
-
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.WARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.DuplicateObjectException;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-import org.eclipse.jst.j2ee.webapplication.ErrorPage;
-import org.eclipse.jst.j2ee.webapplication.WebAppResource;
-import org.eclipse.jst.j2ee.webapplication.WebType;
-import org.eclipse.jst.j2ee.webapplication.WebapplicationFactory;
-import org.eclipse.jst.j2ee.webapplication.WebapplicationPackage;
-import org.eclipse.jst.j2ee.webapplication.internal.impl.FilterMappingImpl;
-import org.eclipse.wst.common.internal.emf.resource.RendererFactory;
-
-
-public class WarEMFEditTest extends GeneralEMFEditingTest {
- protected EARFile earFile;
- protected WARFile warFile;
- protected int createdWebTypes = 0;
- protected int createdErrorPages = 0;
- protected boolean fmFlag = false;
-
- public WarEMFEditTest(String name) {
- super(name);
- }
-
- public WarEMFEditTest(String name, RendererFactory factory) {
- super(name, factory);
- }
-
- public static void main(java.lang.String[] args) {
- String[] className = { "com.ibm.etools.archive.test.WarEMFTest", "-noloading" };
- TestRunner.main(className);
- }
- public static junit.framework.Test suite(RendererFactory factory) {
- TestSuite suite = new TestSuite(WarEMFEditTest.class.getName());
- suite.addTest(new WarEMFEditTest("testWAREdit",factory));
- return suite;
- }
-
- public void testWAREdit() throws Exception {
- getWARClient();
-
- WebAppResource DD = (WebAppResource) warFile.getDeploymentDescriptorResource();
- setVersion(VERSION_1_3);
- setModuleType(WEB);
- editRoot(DD.getRootObject());
- String curDir = AutomatedBVT.baseDirectory;
- String out = curDir + "testOutput/EMFModelCreationTests/EditWarEAR";
- warFile.extractTo(out, Archive.EXPAND_ALL);
- warFile.close();
-
- //Compare work in progress
-
- String exampleDeploymentDesURI = curDir + "EMFTests/web.xml";
- String curDeploymentDesURI = curDir + out + "/fooWAR/WEB-INF/web.xml";
- //compareContents(curDeploymentDesURI, exampleDeploymentDesURI);
- }
-
- public void getWARClient() throws DuplicateObjectException, OpenFailureException {
- String in = AutomatedBVT.baseDirectory + "loose_module_workspace/LooseEARWeb/webApplication/";
- warFile = getArchiveFactory().openWARFile(in);
- assertTrue(warFile.getDeploymentDescriptor() != null);
- }
- public EObject createInstance(EClass eClassifier) {
-
- if (WebapplicationPackage.eINSTANCE.getWebType().equals(eClassifier))
- return createWebType();
- else if (WebapplicationPackage.eINSTANCE.getErrorPage().equals(eClassifier))
- return createErrorPage();
-
- return super.createInstance(eClassifier);
- }
- /* The web type is abstract. Alternate between servlet-class
- * and jsp-file
- */
- public WebType createWebType() {
- createdWebTypes++;
- if ((createdWebTypes & 1) == 0)
- return WebapplicationFactory.eINSTANCE.createServletType();
- else
- return WebapplicationFactory.eINSTANCE.createJSPType();
-
- }
- /* The error page is abstract. Alternate between exceptiontype
- * and error code
- */
- public ErrorPage createErrorPage() {
- createdErrorPages++;
- if ((createdErrorPages & 1) == 0)
- return WebapplicationFactory.eINSTANCE.createErrorCodeErrorPage();
- else
- return WebapplicationFactory.eINSTANCE.createExceptionTypeErrorPage();
- }
- /* (non-Javadoc)
- * @see com.ibm.etools.archive.emftest.GeneralEMFPopulationTest#populateAttributes(org.eclipse.emf.ecore.EObject)
- */
- protected void populateAttributes(EObject eObject) {
- if (eObject instanceof FilterMappingImpl){
- List attributes = eObject.eClass().getEAllAttributes();
- for (int i = 0; i < attributes.size(); i++) {
- EAttribute att = (EAttribute) attributes.get(i);
- if(att.getName().equals("urlPattern") && fmFlag){
- continue;
- }
-
- Object value = createAttributeValue(att, eObject);
- if (att.isChangeable())
- eObject.eSet(att, value);
- }
- fmFlag = !fmFlag;
- }
- else
- super.editAttributes(eObject);
- }
-
-
- protected void populateSharedReference(EObject eObject, EReference ref) {
- if(eObject instanceof FilterMappingImpl && ref.getName().equals("servlet")){
- fmFlag = !fmFlag;
- //if method permission unchecked ignore roles
- if(!fmFlag){
- return;
- }
- }
- super.populateSharedReference(eObject, ref);
- }
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/WarEMFTest.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/WarEMFTest.java
deleted file mode 100644
index d036e704..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/WarEMFTest.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.archive.emftests;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestSuite;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.jst.j2ee.archive.testutilities.EMFAttributeFeatureGenerator;
-import org.eclipse.jst.j2ee.common.ResAuthTypeBase;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.WARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.DuplicateObjectException;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveOptions;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
-import org.eclipse.jst.j2ee.webapplication.ErrorPage;
-import org.eclipse.jst.j2ee.webapplication.WebAppResource;
-import org.eclipse.jst.j2ee.webapplication.WebType;
-import org.eclipse.jst.j2ee.webapplication.WebapplicationFactory;
-import org.eclipse.jst.j2ee.webapplication.WebapplicationPackage;
-import org.eclipse.jst.j2ee.webapplication.internal.impl.FilterMappingImpl;
-import org.eclipse.wst.common.internal.emf.resource.RendererFactory;
-
-
-public class WarEMFTest extends GeneralEMFPopulationTest {
- protected EARFile earFile;
- protected WARFile warFile;
- protected int createdWebTypes = 0;
- protected int createdErrorPages = 0;
- protected boolean fmFlag = false;
-
- public WarEMFTest(String name) {
- super(name);
- }
-
- public WarEMFTest(String name, RendererFactory factory) {
- super(name, factory);
- }
-
- public static void main(java.lang.String[] args) {
- junit.textui.TestRunner.main(new String[]{ WarEMFTest.class.getName() });
- }
-
- public static junit.framework.Test suite(RendererFactory factory) {
- TestSuite suite = new TestSuite(WarEMFTest.class.getName());
- //[248158] suite.addTest(new WarEMFTest("testWARPopulation",factory));
- suite.addTest(new WarEMFTest("test14WARPopulation",factory));
- return suite;
- }
-
- public void testWARPopulation() throws Exception {
- EMFAttributeFeatureGenerator.reset();
- createEAR();
- createWARClient();
-
- WebAppResource DD = (WebAppResource) warFile.getDeploymentDescriptorResource();
- DD.setVersionID(J2EEVersionConstants.J2EE_1_3_ID);
- //TODO: individual test for each version
- setVersion(VERSION_1_3);
- setModuleType(WEB);
- populateRoot(DD.getRootObject());
-
- String out = AutomatedBVT.baseDirectory +"testOutput/TestWarEAR";
- earFile.extractTo(out, Archive.EXPAND_ALL);
- earFile.close();
-
- //Compare work in progress
- String curDir = AutomatedBVT.baseDirectory;
- String exampleDeploymentDesURI = curDir + "EMFTestNoID/web.xml";
- String curDeploymentDesURI = curDir + "testOutput/TestWarEAR/fooWAR/WEB-INF/web.xml";
- setIgnoreAtt(ignorableAttributes());
- setEquivalentLines(getEquivalentLinesMap());
- compareContentsIgnoreWhitespace(curDeploymentDesURI, exampleDeploymentDesURI, null);
- }
-
- public void test14WARPopulation() throws Exception {
- EMFAttributeFeatureGenerator.reset();
- createEAR();
- createWARClient();
-
- WebAppResource DD = (WebAppResource) warFile.getDeploymentDescriptorResource();
- DD.setVersionID(J2EEVersionConstants.J2EE_1_4_ID);
- //TODO: individual test for each version
- setVersion(VERSION_1_4);
- setModuleType(WEB);
- //setGeneralDepth(2);
- populateRoot(DD.getRootObject());
-
- String out = AutomatedBVT.baseDirectory +"testOutput/TestWarEAR14";
- earFile.extractTo(out, Archive.EXPAND_ALL);
- earFile.close();
-
- getWARClient();
- assertEquals("2.4", warFile.getDeploymentDescriptor().getVersion());
- out = AutomatedBVT.baseDirectory +"testOutput/TestWarEAR14_2";
- warFile.extractTo(out, Archive.EXPAND_ALL);
- warFile.close();
-
- //Compare work in progress
- String curDir = AutomatedBVT.baseDirectory;
- String exampleDeploymentDesURI = out + "/WEB-INF/web.xml";
- String curDeploymentDesURI = curDir + "testOutput/TestWarEAR14/fooWAR/WEB-INF/web.xml";
- setIgnoreAtt(ignorableAttributes());
- compareContentsIgnoreWhitespace(curDeploymentDesURI, exampleDeploymentDesURI, null);
- }
-
- /**
- * @return
- */
- private Map getEquivalentLinesMap() {
- Map lines = new HashMap();
- lines.put("<distributable></distributable>", "<distributable/>");
- return lines;
- }
-
- public void createWARClient() throws DuplicateObjectException {
- warFile = getArchiveFactory().createWARFileInitialized("fooWAR");
- warFile = (WARFile) earFile.addCopy(warFile);
- warFile.getDeploymentDescriptor().setDisplayName("fooWAR");
- assertTrue(warFile.getDeploymentDescriptor() != null);
- }
-
- public void createEAR() {
- String earName = "Test.ear";
- earFile = getArchiveFactory().createEARFileInitialized(earName);
- assertTrue(earFile.getDeploymentDescriptor() != null);
- }
-
- public void getWARClient() throws DuplicateObjectException, OpenFailureException {
- String in = AutomatedBVT.baseDirectory + "testOutput/TestWarEAR14/fooWAR";
- ArchiveOptions options = new ArchiveOptions();
- options.setRendererType(options.SAX);
- warFile = getArchiveFactory().openWARFile(options, in);
- assertTrue(warFile.getDeploymentDescriptor() != null);
- }
-
- public EObject createInstance(EReference ref,EObject eObject) {
-
- if (WebapplicationPackage.eINSTANCE.getWebType().equals(ref.getEType()))
- return createWebType();
- else if (WebapplicationPackage.eINSTANCE.getErrorPage().equals(ref.getEType()))
- return createErrorPage();
-
- return super.createInstance(ref, eObject);
- }
- /* The web type is abstract. Alternate between servlet-class
- * and jsp-file
- */
- public WebType createWebType() {
- createdWebTypes++;
- if ((createdWebTypes & 1) == 0)
- return WebapplicationFactory.eINSTANCE.createServletType();
- else
- return WebapplicationFactory.eINSTANCE.createJSPType();
-
- }
- /* The error page is abstract. Alternate between exceptiontype
- * and error code
- */
- public ErrorPage createErrorPage() {
- createdErrorPages++;
- if ((createdErrorPages & 1) == 0)
- return WebapplicationFactory.eINSTANCE.createErrorCodeErrorPage();
- else
- return WebapplicationFactory.eINSTANCE.createExceptionTypeErrorPage();
- }
- /* (non-Javadoc)
- * @see com.ibm.etools.archive.emftest.GeneralEMFPopulationTest#populateAttributes(org.eclipse.emf.ecore.EObject)
- */
- protected void populateAttributes(EObject eObject) {
- if (eObject instanceof FilterMappingImpl){
- List attributes = eObject.eClass().getEAllAttributes();
- for (int i = 0; i < attributes.size(); i++) {
- EAttribute att = (EAttribute) attributes.get(i);
- if(att.getName().equals("urlPattern") && fmFlag){
- continue;
- }
-
- Object value = createAttributeValue(att, eObject);
- if (att.isChangeable())
- eObject.eSet(att, value);
- }
- fmFlag = !fmFlag;
- }
- else
- super.populateAttributes(eObject);
- }
-
-
- protected void populateSharedReference(EObject eObject, EReference ref) {
- if(eObject instanceof FilterMappingImpl && ref.getName().equals("servlet")){
- fmFlag = !fmFlag;
- //if method permission unchecked ignore roles
- if(!fmFlag){
- return;
- }
- }
- super.populateSharedReference(eObject, ref);
- }
-
- protected boolean isValidAuth(ResAuthTypeBase auth) {
- if (version == VERSION_1_2)
- return auth == ResAuthTypeBase.SERVLET_LITERAL || auth == ResAuthTypeBase.CONTAINER_LITERAL;
- else
- return super.isValidAuth(auth);
- }
-
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/WebServicesEMFTest.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/WebServicesEMFTest.java
deleted file mode 100644
index d9e6b183..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/emftests/WebServicesEMFTest.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Aug 6, 2003
- *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.jst.j2ee.archive.emftests;
-
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.jst.j2ee.archive.testutilities.EMFAttributeFeatureGenerator;
-import org.eclipse.jst.j2ee.common.internal.impl.J2EEResourceFactoryRegistry;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EJBJarFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.DuplicateObjectException;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.OpenFailureException;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
-import org.eclipse.jst.j2ee.webservice.jaxrpcmap.InterfaceMapping;
-import org.eclipse.jst.j2ee.webservice.jaxrpcmap.JavaWSDLMapping;
-import org.eclipse.jst.j2ee.webservice.jaxrpcmap.JaxrpcmapFactory;
-import org.eclipse.jst.j2ee.webservice.jaxrpcmap.JaxrpcmapPackage;
-import org.eclipse.jst.j2ee.webservice.jaxrpcmap.JaxrpcmapResource;
-import org.eclipse.jst.j2ee.webservice.jaxrpcmap.JaxrpcmapResourceFactory;
-import org.eclipse.jst.j2ee.webservice.wsclient.WebServicesResource;
-import org.eclipse.jst.j2ee.webservice.wsdd.WsddFactory;
-import org.eclipse.jst.j2ee.webservice.wsdd.WsddResource;
-import org.eclipse.wst.common.internal.emf.resource.RendererFactory;
-
-
-/**
- * @author dfholttp
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class WebServicesEMFTest extends GeneralEMFPopulationTest {
- public EARFile earFile;
- public EJBJarFile ejbFile;
- int currentVersion = J2EEVersionConstants.J2EE_1_3_ID;
- private int createdInterfaceMaps = 0;
-
- public WebServicesEMFTest(String name) {
- super(name);
- }
-
- public WebServicesEMFTest(String name, RendererFactory factory) {
- super(name, factory);
- }
-
- public static void main(java.lang.String[] args) {
- String[] className = { "com.ibm.etools.archive.test.WebServicesEMFTest", "-noloading" };
- TestRunner.main(className);
- }
- public static junit.framework.Test suite(RendererFactory factory) {
- TestSuite suite = new TestSuite(WebServicesEMFTest.class.getName());
- suite.addTest(new WebServicesEMFTest("test13WebServicesClientPopulation",factory));
- suite.addTest(new WebServicesEMFTest("test13WebServicesDDPopulation",factory));
- suite.addTest(new WebServicesEMFTest("test14WebServicesDDPopulation",factory));
- suite.addTest(new WebServicesEMFTest("test50WebServicesDDPopulation",factory));
- suite.addTest(new WebServicesEMFTest("testJaxRPCMapPopulation",factory));
- return suite;
- }
-
- public void test13WebServicesClientPopulation() throws Exception {
- currentVersion = J2EEVersionConstants.J2EE_1_3_ID;
- EMFAttributeFeatureGenerator.reset();
- createEAR();
- createEJB();
-
-
- WebServicesResource webserDD = (WebServicesResource)ejbFile.getResourceSet().createResource(URI.createURI("META-INF/webservicesclient.xml"));
- //TODO: individual test for each version
- webserDD.setVersionID(currentVersion);
- setVersion(VERSION_1_3);
- populateRoot(webserDD.getRootObject());
-
- String out = AutomatedBVT.baseDirectory +getProjectLocation();
- earFile.extractTo(out, Archive.EXPAND_ALL);
- earFile.close();
-
- }
-
- public void testJaxRPCMapPopulation() throws Exception {
- currentVersion = J2EEVersionConstants.J2EE_1_3_ID;
- EMFAttributeFeatureGenerator.reset();
- createEAR();
- createEJB();
- String mappingFilePathURI = "META-INF/testmap.xml";
- URI uri = URI.createURI(mappingFilePathURI);
- ResourceSet resSet = ejbFile.getResourceSet();
- J2EEResourceFactoryRegistry registry = (J2EEResourceFactoryRegistry) resSet.getResourceFactoryRegistry();
- registry.registerLastFileSegment(uri.lastSegment(), new JaxrpcmapResourceFactory(RendererFactory.getDefaultRendererFactory()));
- resSet = earFile.getResourceSet();
- registry = (J2EEResourceFactoryRegistry) resSet.getResourceFactoryRegistry();
- registry.registerLastFileSegment(uri.lastSegment(), new JaxrpcmapResourceFactory(RendererFactory.getDefaultRendererFactory()));
-
- JaxrpcmapResource jaxrpcmapRes = (JaxrpcmapResource) resSet.createResource(uri);
-
- jaxrpcmapRes.setVersionID(currentVersion);
- setVersion(VERSION_1_3);
-
- JavaWSDLMapping map = JaxrpcmapFactory.eINSTANCE.createJavaWSDLMapping();
- jaxrpcmapRes.getContents().add(map);
- populateRoot(jaxrpcmapRes.getRootObject());
-
- String out = AutomatedBVT.baseDirectory +getProjectLocation();
- earFile.extractTo(out, Archive.EXPAND_ALL);
- earFile.close();
-
- }
-
- public void test13WebServicesDDPopulation() throws Exception {
- EMFAttributeFeatureGenerator.reset();
- currentVersion = J2EEVersionConstants.J2EE_1_3_ID;
- createEAR();
- createEJB();
-
- WsddResource webserDD = (WsddResource)ejbFile.getResourceSet().createResource(URI.createURI("META-INF/webservices.xml"));
- //TODO: individual test for each version
- webserDD.setVersionID(currentVersion);
- setVersion(VERSION_1_3);
- populateRoot(webserDD.getRootObject());
-
- String out = AutomatedBVT.baseDirectory +getProjectLocation();
- earFile.extractTo(out, Archive.EXPAND_ALL);
- earFile.close();
-
- }
- public void test14WebServicesDDPopulation() throws Exception {
- EMFAttributeFeatureGenerator.reset();
- currentVersion = J2EEVersionConstants.J2EE_1_4_ID;
- createEAR();
- createEJB();
-
- WsddResource webserDD = (WsddResource)ejbFile.getResourceSet().createResource(URI.createURI("META-INF/webservices.xml"));
- webserDD.getContents().add(WsddFactory.eINSTANCE.createWebServices());
- //TODO: individual test for each version
- webserDD.setVersionID(currentVersion);
- setVersion(VERSION_1_4);
- populateRoot(webserDD.getRootObject());
-
- String out = AutomatedBVT.baseDirectory +getProjectLocation();
- earFile.extractTo(out, Archive.EXPAND_ALL);
- earFile.close();
-
- }
- public void test50WebServicesDDPopulation() throws Exception {
- EMFAttributeFeatureGenerator.reset();
- currentVersion = J2EEVersionConstants.JEE_5_0_ID;
- createEAR();
- createEJB();
-
- WsddResource webserDD = (WsddResource)ejbFile.getResourceSet().createResource(URI.createURI("META-INF/webservices.xml"));
- webserDD.getContents().add(WsddFactory.eINSTANCE.createWebServices());
- //TODO: individual test for each version
- webserDD.setVersionID(currentVersion);
- setVersion(VERSION_5_0);
- populateRoot(webserDD.getRootObject());
-
- String out = AutomatedBVT.baseDirectory +getProjectLocation();
- earFile.extractTo(out, Archive.EXPAND_ALL);
- earFile.close();
-
- }
-
- public EObject createInstance(EReference ref,EObject eObject) {
-
- if (JaxrpcmapPackage.eINSTANCE.getInterfaceMapping().equals(ref.getEType()))
- return createInterfaceMap();
-
- return super.createInstance(ref, eObject);
- }
-
- /* The web type is abstract. Alternate between servlet-class
- * and jsp-file
- */
- public InterfaceMapping createInterfaceMap() {
- createdInterfaceMaps++;
- if ((createdInterfaceMaps & 1) == 0)
- return JaxrpcmapFactory.eINSTANCE.createServiceEndpointInterfaceMapping();
- else
- return JaxrpcmapFactory.eINSTANCE.createServiceEndpointInterfaceMapping();
-
- }
-
- public String getProjectLocation() {
- if (currentVersion == J2EEVersionConstants.J2EE_1_3_ID)
- return "testOutput/TestWebServices";
- if (currentVersion == J2EEVersionConstants.J2EE_1_4_ID)
- return "testOutput/TestWebServices14";
- else
- return "testOutput/TestWebServices50";
- }
- public void getEJB() throws DuplicateObjectException, OpenFailureException {
- String in = AutomatedBVT.baseDirectory +getProjectLocation() +"/fooWebServices";
- ejbFile = getArchiveFactory().openEJBJarFile(in);
- assertTrue(ejbFile.getDeploymentDescriptor() != null);
- }
- public void createEJB() throws DuplicateObjectException {
- ejbFile = getArchiveFactory().createEJBJarFileInitialized("fooWebServices");
- ejbFile = (EJBJarFile) earFile.addCopy(ejbFile);
- ejbFile.getDeploymentDescriptor().setDisplayName("fooWebServices");
- assertTrue(ejbFile.getDeploymentDescriptor() != null);
- }
- public void createEAR() {
- String earName = "Test.ear";
- earFile = getArchiveFactory().createEARFileInitialized(earName);
- assertTrue(earFile.getDeploymentDescriptor() != null);
- }
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/AbstractArchiveTest.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/AbstractArchiveTest.java
deleted file mode 100644
index 491a319d..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/AbstractArchiveTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package org.eclipse.jst.j2ee.archive.test;
-
- /*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2001 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- */
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchiveFactory;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchivePackage;
-/**
- * Insert the type's description here.
- * Creation date: (02/07/01 1:48:18 PM)
- * @author: Administrator
- */
-public class AbstractArchiveTest extends junit.framework.TestCase {
- private final static String copyright = "(c) Copyright IBM Corporation 2001.";//$NON-NLS-1$
-/**
- * AbstractArchiveTest constructor comment.
- * @param name java.lang.String
- */
-public AbstractArchiveTest(String name) {
- super(name);
-}
-public Set getAllUnresolvedProxies(EObject root) {
- Set visited = new HashSet();
- Set proxies = new HashSet();
- getAllUnresolvedProxies(root, proxies, visited, root.eResource());
- return proxies;
-}
-public void getAllUnresolvedProxies(EObject object, Set proxies, Set visitedObjects, Resource originalResource) {
-
- if (visitedObjects.contains(object))
- return;
- else
- visitedObjects.add(object);
-
- if (object.eResource() != originalResource) {
- if (((org.eclipse.emf.ecore.InternalEObject )object).eIsProxy()) {
- proxies.add(object);
- }
- return;
- }
-
- List refs = object.eClass().getEAllReferences();
- if (refs != null) {
- Iterator ir = refs.iterator();
- while (ir.hasNext()) {
- EReference r = (EReference) ir.next();
- Object value = object.eGet(r);
- if (value == null)
- continue;
-
- if (r.isMany()) {
- Collection c = (Collection) value;
- Iterator ir2 = c.iterator();
- while (ir2.hasNext()) {
- EObject refObj = (EObject) ir2.next();
- getAllUnresolvedProxies(refObj, proxies, visitedObjects, originalResource);
- }
- } else
- getAllUnresolvedProxies((EObject) value, proxies, visitedObjects, originalResource);
- }
- }
-}
-public static CommonarchiveFactory getArchiveFactory() {
- return CommonarchivePackage.eINSTANCE.getCommonarchiveFactory();
-}
-public void verifyProxies(EObject root) {
-
- Set proxies = getAllUnresolvedProxies(root);
- assertTrue("Some proxies could not be resolved", proxies.isEmpty());
-}
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/AllArchiveTestsEclipse.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/AllArchiveTestsEclipse.java
deleted file mode 100644
index 449fc6e1..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/AllArchiveTestsEclipse.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Created on Apr 18, 2003
- *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.jst.j2ee.archive.test;
-
-/**
- * @author jsholl
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class AllArchiveTestsEclipse extends AllArchiveTestsJava {
-
- public AllArchiveTestsEclipse(String name) {
- super(name);
- }
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/AllArchiveTestsJava.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/AllArchiveTestsJava.java
deleted file mode 100644
index 1a6c8eb8..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/AllArchiveTestsJava.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package org.eclipse.jst.j2ee.archive.test;
-
- /*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2001 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- */
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-/**
- * Insert the type's description here.
- * Creation date: (12/19/00 4:44:04 PM)
- * @author: Administrator
- */
-public class AllArchiveTestsJava extends TestCase {
- private final static String copyright = "(c) Copyright IBM Corporation 2001.";//$NON-NLS-1$
-/**
- * AllTests constructor comment.
- * @param name java.lang.String
- */
-public AllArchiveTestsJava(String name) {
- super(name);
-}
-/**
- * Starts the application.
- * @param args an array of command-line arguments
- */
-public static void main(java.lang.String[] args) {
- String[] className = {"com.ibm.etools.archive.test.AllTests", "-noloading"};
- TestRunner.main(className);
-}
-public static junit.framework.Test suite() {
- TestSuite suite = new TestSuite("Test for com.ibm.etools.archive.test");
- suite.addTest(DiscriminatorTest.suite());
- suite.addTest(LooseArchiveTests.suite());
- suite.addTest(InitializationTests.suite());
- suite.addTest(SimpleTests.suite());
- suite.addTest(CopyTests.suite());
-// suite.addTest(EJBJarConversionTests.suite());
- suite.addTest(WARFileTests.suite());
- suite.addTest(SaveTests.suite());
- suite.addTest(JavaTests.suite());
-// suite.addTest(IDTests.suite());
- //suite.addTest(AltDDTests.suite());
- suite.addTest(SecurityRoleTests.suite());
- suite.addTest(RarFileTests.suite());
- suite.addTest(ResourceTests.suite());
- suite.addTest(ClientContainerResourceLoadTest.suite());
- suite.addTest(TestModuleClassLoading.suite());
- suite.addTest(TestInvalidXmlMultiplicity.suite());
- suite.addTest(DefectVerificationTests.suite());
-
- return suite;
-}
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/ClientContainerResourceLoadTest.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/ClientContainerResourceLoadTest.java
deleted file mode 100644
index 5ed8198f..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/ClientContainerResourceLoadTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package org.eclipse.jst.j2ee.archive.test;
-
-import java.io.FileNotFoundException;
-import java.util.List;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.ApplicationClientFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchiveFactory;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.ResourceLoadException;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveInit;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.impl.CommonarchiveFactoryImpl;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-
-
-
-public class ClientContainerResourceLoadTest extends TestCase{
- public static EARFile earFile = null;
-
- private final static String copyright = "(c) Copyright IBM Corporation 2001."; //$NON-NLS-1$
- /**
- * SimpleTests constructor comment.
- * @param name java.lang.String
- */
- public ClientContainerResourceLoadTest(String name) {
- super(name);
- }
-
- protected void setUp() throws Exception {
- // TODO Auto-generated method stub
- super.setUp();
- ArchiveInit.init();
- }
-
-
- public static junit.framework.Test suite() {
- return new TestSuite(ClientContainerResourceLoadTest.class);
- }
- /**
- * Starts the application.
- * @param args an array of command-line arguments
- */
- public static void main(java.lang.String[] args) {
- String[] className = { "com.ibm.etools.archive.test.ClientContainerResourceLoadTest", "-noloading" };
- TestRunner.main(className);
- }
-
- public void testClientContainerLoad () throws Exception {
-
- try {
-
- CommonarchiveFactory factory = CommonarchiveFactoryImpl.getActiveFactory();
- String in = AutomatedBVT.baseDirectory + "mtapp2.ear";
- String out = AutomatedBVT.baseDirectory + "mtapp2Finished.ear";
- earFile = factory.openEARFile (in);
- System.out.println ("uri: " + earFile.getURI());
-
- List appClients = earFile.getApplicationClientFiles();
- boolean exFound1 = false;
- boolean exFound2 = false;
-
- for(int i = 0; i<appClients.size(); i++){
- ApplicationClientFile file = (ApplicationClientFile)appClients.get(0);
- Resource res;
-
- try{
- res = file.getMofResource("META-INF/FOOclient-resource.xmi");
- } catch(Exception e){
- exFound1 = true;
- if(!(e instanceof FileNotFoundException)){
- assertTrue("Expected FileNotFoundException", false);
- }
- }
-
- try {
- res = file.getMofResource("META-INF/client-resource.xmi");
- } catch (Exception e) {
- exFound2 = true;
- if(!(e instanceof ResourceLoadException)){
- assertTrue("Expected ResourceLoadException", false);
- }
- }
- }
- assertTrue("No exception logged for non-existing file", exFound1);
- assertTrue("No exception logged for existing", exFound2);
-
-
- earFile.saveAs(out);
- earFile.close();
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/CopyTests.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/CopyTests.java
deleted file mode 100644
index 3ae6167d..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/CopyTests.java
+++ /dev/null
@@ -1,234 +0,0 @@
-package org.eclipse.jst.j2ee.archive.test;
-
-/*
-* Licensed Material - Property of IBM
-* (C) Copyright IBM Corp. 2001 - All Rights Reserved.
-* US Government Users Restricted Rights - Use, duplication or disclosure
-* restricted by GSA ADP Schedule Contract with IBM Corp.
-*/
-
-import java.util.Iterator;
-import java.util.List;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-
-import org.eclipse.jst.j2ee.application.Module;
-import org.eclipse.jst.j2ee.application.WebModule;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchiveFactory;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchivePackage;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EJBJarFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EJBModuleRef;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.File;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.ReadOnlyDirectory;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.WARFile;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-import org.eclipse.jst.j2ee.ejb.EjbFactory;
-import org.eclipse.jst.j2ee.ejb.EjbPackage;
-import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
-import org.eclipse.jst.j2ee.webapplication.WebapplicationFactory;
-import org.eclipse.jst.j2ee.webapplication.WebapplicationPackage;
-
-
-/**
- * Insert the type's description here.
- * Creation date: (12/14/00 12:10:36 PM)
- * @author: Administrator
- */
-public class CopyTests extends TestCase {
- private final static String copyright = "(c) Copyright IBM Corporation 2001."; //$NON-NLS-1$
- /**
- * CopyTests constructor comment.
- * @param name java.lang.String
- */
- public CopyTests(String name) {
- super(name);
- }
- public CommonarchiveFactory getArchiveFactory() {
- return CommonarchivePackage.eINSTANCE.getCommonarchiveFactory();
- }
- public EjbFactory getEJBFactory() {
- return EjbPackage.eINSTANCE.getEjbFactory();
- }
-
- public EjbPackage getEJBPackage() {
- return EjbPackage.eINSTANCE;
- }
- public WebapplicationFactory getWebFactory() {
- return WebapplicationPackage.eINSTANCE.getWebapplicationFactory();
- }
- /**
- * Starts the application.
- * @param args an array of command-line arguments
- */
- public static void main(java.lang.String[] args) {
- String[] className = { "com.ibm.etools.archive.test.CopyTests", "-noloading" };
- TestRunner.main(className);
- }
- public static junit.framework.Test suite() {
- return new TestSuite(CopyTests.class);
- }
- /**
- * Tests the addCopy(ReadOnlyDirectory) api on archive
- */
- public void testAddCopyDirectory() throws Exception {
-
- WARFile aWarFile = (WARFile) getArchiveFactory().openArchive(AutomatedBVT.baseDirectory + "example2.war");
-
- ReadOnlyDirectory sampleDirectory = getArchiveFactory().openReadOnlyDirectory(AutomatedBVT.baseDirectory + "WarTestClasses");
-
- int initialSize = aWarFile.getFiles().size();
-
- aWarFile.addCopy(sampleDirectory);
- Iterator iter = aWarFile.getFiles().iterator();
- //For running inside eclipse
- while (iter.hasNext()) {
- String uri = ((File)iter.next()).getURI();
- if (uri.indexOf("CVS") >= 0)
- iter.remove();
- }
- assertTrue("Wrong number of files ", aWarFile.getFiles().size() == initialSize + 7);
- aWarFile.saveAsNoReopen(AutomatedBVT.baseDirectory + "testOutput/CopyTests/addCopyDir.war");
-
- }
-
- public void testAddCopyModule() throws Exception {
-
- String in = AutomatedBVT.baseDirectory + "sample.ear";
- EARFile earFile = (EARFile) getArchiveFactory().openArchive(in);
- List modules = earFile.getDeploymentDescriptor().getModules();
- EJBJarFile ejbJarFile = null;
-
- for (int i = 0; i < modules.size(); i++) {
- Module aModule = (Module) modules.get(i);
- if (aModule.isEjbModule()) {
- ejbJarFile = (EJBJarFile) earFile.getFile(aModule.getUri());
- break;
- }
- }
-
- assertTrue("EJBJarFile should not be null", ejbJarFile != null);
- ejbJarFile.getDeploymentDescriptor();
-
- EARFile newEarFile = getArchiveFactory().createEARFileInitialized(AutomatedBVT.baseDirectory + "testOutput/CopyTests/newEarWithCopiedModule.ear");
- newEarFile.addCopy(ejbJarFile);
- EJBJarFile copied = (EJBJarFile) newEarFile.getModuleFiles().get(0);
- assertTrue(copied.isDeploymentDescriptorSet());
- assertTrue(copied.getDeploymentDescriptor() == copied.getDeploymentDescriptorResource().getContents().get(0));
- assertTrue(copied.getDeploymentDescriptor() != ejbJarFile.getDeploymentDescriptor());
- assertTrue(ejbJarFile.getFiles().size() == copied.getFiles().size());
-
- newEarFile.saveNoReopen();
- }
-
- /**
- * Test per CMVC defect report 96197
- * Create a new application, open ejb jar file, use addcopy to add the module, and save
- * using original ear, get the ejb jar, and modify bindings
- * save again
- * Result: bindings not updated
- */
- public void testAddCopyModuleFilesToEAR() throws Exception {
- String uri = AutomatedBVT.baseDirectory + "testOutput/CopyTests/testAddCopyModuleFilesToEAR.ear";
- //Create a new ear file, add a standalone ejb jar file and standalone war file, and save
- EARFile earFile = getArchiveFactory().createEARFileInitialized(uri);
- earFile.setJ2EEVersion(J2EEVersionConstants.J2EE_1_3_ID);
- earFile.getDeploymentDescriptor().setDisplayName(uri);
- EJBJarFile ejbJarFile = getArchiveFactory().openEJBJarFile(AutomatedBVT.baseDirectory + "bankejbs.jar");
- earFile.addCopy(ejbJarFile);
- WARFile warFile = getArchiveFactory().openWARFile(AutomatedBVT.baseDirectory + "example2.war");
- earFile.addCopy(warFile);
- ((WebModule) earFile.getDeploymentDescriptor().getFirstModule(warFile.getURI())).setContextRoot("/");
- earFile.save();
-
- ejbJarFile = (EJBJarFile) earFile.getEJBJarFiles().get(0);
- assertTrue("ejb dd resource not right", ejbJarFile.getDeploymentDescriptor().eResource() == ejbJarFile.getDeploymentDescriptorResource());
-
-
-
- warFile = (WARFile) earFile.getWARFiles().get(0);
- assertTrue("war dd resource not right", warFile.getDeploymentDescriptor().eResource() == warFile.getDeploymentDescriptorResource());
-
-
- earFile.saveNoReopen();
-
-
- earFile.close();
-
- }
- /**
- * Tests opening a standalone module with an absolute path, and adding that to a new ear file, per defect report
- */
- public void testAddCopyStandaloneModule() throws Exception {
- String fileName = AutomatedBVT.baseDirectory + "bankejbs.jar";
-
- EJBJarFile ejbJarFile = (EJBJarFile) getArchiveFactory().openArchive(fileName);
- ejbJarFile.getDeploymentDescriptor();
-
- EARFile newEarFile = getArchiveFactory().createEARFileInitialized(AutomatedBVT.baseDirectory + "testOutput/CopyTests/newEarWithStandAloneModule-out.ear");
- newEarFile.addCopy(ejbJarFile);
- EJBJarFile copied = (EJBJarFile) newEarFile.getModuleFiles().get(0);
- assertTrue(copied.isDeploymentDescriptorSet());
- assertTrue(copied.getDeploymentDescriptor() == copied.getDeploymentDescriptorResource().getContents().get(0));
- assertTrue(copied.getDeploymentDescriptor() != ejbJarFile.getDeploymentDescriptor());
- assertTrue(ejbJarFile.getFiles().size() == copied.getFiles().size());
-
- newEarFile.saveNoReopen();
- }
-
- public void testAddRenameAndDelete() throws Exception {
-
- String in = AutomatedBVT.baseDirectory + "sample.ear";
- EARFile earFile = (EARFile) getArchiveFactory().openArchive(in);
- List modules = earFile.getDeploymentDescriptor().getModules();
- EJBJarFile ejbJarFile = null;
-
- for (int i = 0; i < modules.size(); i++) {
- Module aModule = (Module) modules.get(i);
- if (aModule.isEjbModule()) {
- ejbJarFile = (EJBJarFile) earFile.getFile(aModule.getUri());
- break;
- }
- }
-
- assertTrue("EJBJarFile should not be null", ejbJarFile != null);
- ejbJarFile.getDeploymentDescriptor();
-
- EARFile newEarFile = getArchiveFactory().createEARFileInitialized(AutomatedBVT.baseDirectory + "testOutput/CopyTests/newEarWithCopiedModule.ear");
- EJBModuleRef addedCopy = (EJBModuleRef) newEarFile.addCopyRef(ejbJarFile);
- assertTrue("Module files should not be empty", !newEarFile.getModuleFiles().isEmpty());
- assertTrue("Modules should not be empty", !newEarFile.getDeploymentDescriptor().getModules().isEmpty());
- assertTrue("Module should be accessible and have the same uri as file", addedCopy.getModule().getUri().equals(addedCopy.getModuleFile().getURI()));
-
- String newURI = "temp/foobar.jar";
- addedCopy.setURI(newURI);
- assertTrue("Module should be accessible and have the new renamed uri as well as the file", addedCopy.getModule().getUri().equals(addedCopy.getModuleFile().getURI()) && addedCopy.getModule().getUri().equals(newURI));
- newEarFile.remove(addedCopy);
- assertTrue("Module files should be empty", newEarFile.getModuleFiles().isEmpty());
- assertTrue("Modules should be empty", newEarFile.getDeploymentDescriptor().getModules().isEmpty());
-
- }
-
- public void testAddRenameAndDeleteStandalone() throws Exception {
-
- String fileName = AutomatedBVT.baseDirectory + "bankejbs.jar";
-
- EJBJarFile ejbJarFile = (EJBJarFile) getArchiveFactory().openArchive(fileName);
-
- EARFile newEarFile = getArchiveFactory().createEARFileInitialized(AutomatedBVT.baseDirectory + "testOutput/CopyTests/newEarWithCopiedModule.ear");
- EJBModuleRef addedCopy = (EJBModuleRef) newEarFile.addCopyRef(ejbJarFile);
- assertTrue("Module files should not be empty", !newEarFile.getModuleFiles().isEmpty());
- assertTrue("Modules should not be empty", !newEarFile.getDeploymentDescriptor().getModules().isEmpty());
- assertTrue("Module should be accessible and have the same uri as file", addedCopy.getModule().getUri().equals(addedCopy.getModuleFile().getURI()));
-
- String newURI = "temp/foobar.jar";
- addedCopy.setURI(newURI);
- assertTrue("Module should be accessible and have the new renamed uri as well as the file", addedCopy.getModule().getUri().equals(addedCopy.getModuleFile().getURI()) && addedCopy.getModule().getUri().equals(newURI));
- newEarFile.remove(addedCopy);
- assertTrue("Module files should be empty", newEarFile.getModuleFiles().isEmpty());
- assertTrue("Modules should be empty", newEarFile.getDeploymentDescriptor().getModules().isEmpty());
-
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/DefectVerificationTests.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/DefectVerificationTests.java
deleted file mode 100644
index 08393f7c..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/DefectVerificationTests.java
+++ /dev/null
@@ -1,389 +0,0 @@
-/*
- * Created on May 20, 2004
- *
- * TODO To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package org.eclipse.jst.j2ee.archive.test;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Iterator;
-import java.util.List;
-import java.util.zip.ZipInputStream;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.j2ee.application.Application;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchiveFactory;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchivePackage;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Container;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EJBModuleRef;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.File;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.ModuleRef;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.WebModuleRef;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveOptions;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-import org.eclipse.jst.j2ee.internal.WrappedException;
-import org.eclipse.jst.j2ee.webapplication.FilterMapping;
-import org.eclipse.jst.j2ee.webapplication.WebApp;
-
-/**
- * @author mdelder
- *
- * TODO To change the template for this generated type comment go to Window -
- * Preferences - Java - Code Generation - Code and Comments
- */
-public class DefectVerificationTests extends TestCase {
-
- /**
- *
- */
- public DefectVerificationTests() {
- super();
- }
-
- /**
- * @param name
- */
- public DefectVerificationTests(String name) {
- super(name);
- }
-
- public static junit.framework.Test suite() {
- /*TestSuite suite = new TestSuite();
- suite.addTest(new DefectVerificationTests("testFilterMappingTranslator"));
- return suite;*/
- return new TestSuite(DefectVerificationTests.class);
- }
-
-
- public void testFilterMappingTranslator() throws Exception {
-/* ArchiveOptions options = new ArchiveOptions();
- options.setRendererType(ArchiveOptions.DOM);
- final String earPath = AutomatedBVT.baseDirectory + "sample.ear";
- CommonarchivePackage pkg = CommonarchivePackage.eINSTANCE;
- EARFile earFile = pkg.getCommonarchiveFactory().openEARFile(options,
- earPath);
- // open the ear
- System.out.println("opening " + archive + " ... ");*/
-
- String archive = AutomatedBVT.baseDirectory + "QIDefectsNew.ear";
- String name = "QIDefects.war";
- /*
- * crack open the ear file using the common archive:
- */
- CommonarchiveFactory archiveFactory = (CommonarchiveFactory) CommonarchivePackage.eINSTANCE.getEFactoryInstance();
- ArchiveOptions options = new ArchiveOptions();
- options.setRendererType(ArchiveOptions.SAX);
- options.setUseJavaReflection(false);
- // options.setDiscriminateNestedArchives(extraProcessing);
-
- EARFile earFile = archiveFactory.openEARFile(options, archive);
- WebModuleRef warFile = null;
- for (Iterator i = earFile.getModuleRefs().iterator(); i.hasNext();) {
- ModuleRef mref = (ModuleRef) i.next();
- if (name.equals(mref.getUri())) {
- warFile = (WebModuleRef) mref;
- }
- }
-
- WebApp dd = (WebApp)warFile.getDeploymentDescriptor();
-
- EList filterMappings = dd.getFilterMappings();
- assertTrue("The test requires two filter mappings.", filterMappings.size() == 2);
- FilterMapping filterMapping1 = (FilterMapping)filterMappings.get(0);
- assertNotNull("A URL Pattern was not found for filter with name " + filterMapping1.getFilter().getName(),filterMapping1.getUrlPattern());
- FilterMapping filterMapping2 = (FilterMapping)filterMappings.get(1);
- assertNotNull("A Servlet name was not found for filter with name " + filterMapping2.getFilter().getName(),filterMapping2.getServletName());
- assertNotNull("A Servlet was not found for filter with name " + filterMapping2.getFilter().getName(),filterMapping2.getServlet());
-
- }
-
- public void testFormerDefect297() throws Exception {
- ArchiveOptions options = new ArchiveOptions();
- options.setRendererType(ArchiveOptions.DOM);
- final String earPath = AutomatedBVT.baseDirectory + "sample.ear";
- CommonarchivePackage pkg = CommonarchivePackage.eINSTANCE;
- EARFile earFile = pkg.getCommonarchiveFactory().openEARFile(options,
- earPath);
- earFile.extractNoReopen(Archive.EXPAND_ALL);
- }
-
- public void testFormerDefect1459() throws Exception {
- ArchiveOptions options = new ArchiveOptions();
- options.setRendererType(ArchiveOptions.DOM);
- CommonarchivePackage pkg = CommonarchivePackage.eINSTANCE;
- CommonarchiveFactory factory = pkg.getCommonarchiveFactory();
-
- EARFile earFile = factory.createEARFileInitialized(options, "Test.ear");
- earFile.saveAs("C:\\Test.ear");
- }
-
- /*
- * public void testCorruptedEAR() throws Exception { ArchiveOptions options =
- * new ArchiveOptions(); options.setRendererType(ArchiveOptions.DOM); final
- * String earPath = AutomatedBVT.baseDirectory + "occam.ear";
- * CommonarchivePackage pkg = CommonarchivePackage.eINSTANCE;
- * CommonarchiveFactory factory = pkg.getCommonarchiveFactory();
- *
- * EARFile earFile = factory.openEARFile(options, earPath);
- *
- * List files = earFile.getFiles();
- *
- * for(int i=0; i <files.size(); i++) { System.err.println(files.get(i));
- * readFile( (File) files.get(i)); if(files.get(i) instanceof WARFile) {
- * WARFile war = (WARFile) files.get(i); List warFiles = war.getFiles();
- * for(int j=0; j <warFiles.size(); j++) {
- * System.err.println(warFiles.get(j)); readFile((File)warFiles.get(j)); } } }
- * System.out.println("Done"); }
- */
-
- /**
- * @param file
- * @throws FileNotFoundException
- * @throws IOException
- */
- private void readFile(File file) throws FileNotFoundException, IOException {
- InputStream is = file.getInputStream();
- ZipInputStream zis = new ZipInputStream(is);
- try {
- while (zis.getNextEntry() != null);
-
- } finally {
- if (is != null)
- is.close();
- if (zis != null)
- zis.close();
- is = null;
- zis = null;
- }
- }
-
- public void testSavingEARWhileDeploying() throws Exception {
- try {
- ArchiveOptions options = new ArchiveOptions();
- options.setRendererType(ArchiveOptions.SAX);
- options.setUseJavaReflection(true);
- final String earPath = AutomatedBVT.baseDirectory
- + "AuctionApp.ear";
- CommonarchivePackage pkg = CommonarchivePackage.eINSTANCE;
- EARFile earFile = pkg.getCommonarchiveFactory().openEARFile(
- options, earPath);
- printFiles(earFile);
- earFile.save();
-
- earFile.reopen();
- } catch (WrappedException we) {
- Logger.getLogger().logError(we);
- Logger.getLogger().logError(we.getMessage());
- if (we.getCause() != null)
- Logger.getLogger().logError(we.getCause());
- if (we.getNestedException() != null)
- Logger.getLogger().logError(we.getNestedException());
- if (we.getNestedException() != null)
- Logger.getLogger().logError(we.getConcatenatedMessages());
- throw we;
- }
- }
-
- public void testCreatingEARFile() throws Exception {
-
- CommonarchivePackage pkg = CommonarchivePackage.eINSTANCE;
- CommonarchiveFactory factory = pkg.getCommonarchiveFactory();
- final String earPath = AutomatedBVT.baseDirectory
- + "InitializedEAR.ear";
-
- ArchiveOptions options = new ArchiveOptions();
- options.setIsReadOnly(true);
- options.setRendererType(ArchiveOptions.DOM);
-
- // new ear file
- EARFile earFile = factory.createEARFileInitialized(options, earPath);
-
- Application appl = earFile.getDeploymentDescriptor();
-
- }
-
- public void testServiceQNameTranslator() throws Exception {
- try {
- ArchiveOptions options = new ArchiveOptions();
- options.setRendererType(ArchiveOptions.SAX);
- final String earPath = AutomatedBVT.baseDirectory + "WSSecured_InsuranceServices_EJB_WS.ear";
- CommonarchivePackage pkg = CommonarchivePackage.eINSTANCE;
- CommonarchiveFactory factory = pkg.getCommonarchiveFactory();
- EARFile earFile = factory.openEARFile(options, earPath);
- printFiles(earFile);
- String tmp = "C:\\temp\\"+System.currentTimeMillis();
- earFile.extractTo(tmp, 0);
-
- List ejbModuleRefs = earFile.getEJBModuleRefs();
-
- for(int i=0; i<ejbModuleRefs.size(); i++) {
- EJBModuleRef ejbmodref = (EJBModuleRef) ejbModuleRefs.get(i);
- if(ejbmodref.getUri().equals("WSInsSession20EJB.jar")) {
- Resource res = ejbmodref.getMofResource("META-INF/webservicesclient.xml");
- System.err.println(res.getURI());
-
- }
- }
- /*
- * Application app = earFile.getDeploymentDescriptor(); List modules =
- * app.getModules(); for(int i=0; i <modules.size(); i++) {
- * System.err.println(modules.get(i)); Module
- * mod=(Module)modules.get(i); if( mod.isEjbModule() ) { EjbModule
- * ejbModule = (EjbModule) mod; EJBJarFile ejbJarFile =
- * factory.openEJBJarFile(options, "WSInsSession20EJB.jar"); EJBJar
- * ejbjar = ejbJarFile.getDeploymentDescriptor(); }
- * }
- */
- } catch (WrappedException we) {
- Logger.getLogger().logError(we);
- Logger.getLogger().logError(we.getMessage());
- if(we.getCause() != null)
- Logger.getLogger().logError(we.getCause());
- if(we.getNestedException() != null)
- Logger.getLogger().logError(we.getNestedException());
- if(we.getNestedException() != null)
- Logger.getLogger().logError(we.getConcatenatedMessages());
- throw we;
- }
- }
-
- public void testReadCrimsonCase() throws Exception {
- try {
- ArchiveOptions options = new ArchiveOptions();
- options.setRendererType(ArchiveOptions.DOM);
- final String earPath = AutomatedBVT.baseDirectory
- + "ejb_sam_Hello.ear";
- CommonarchivePackage pkg = CommonarchivePackage.eINSTANCE;
- EARFile earFile = pkg.getCommonarchiveFactory().openEARFile(
- options, earPath);
- Application app = earFile.getDeploymentDescriptor();
- assertNotNull("Could not read deployment descriptor.", app);
- System.err.println("\n\n******************Printing files from " + app.getDisplayName());
- assertNotNull("Could not read display name from deployment descriptor.", app.getDisplayName());
- printFiles(earFile);
- earFile.extractTo(AutomatedBVT.baseDirectory + "testOutput/temp", 0);
- earFile.reopen();
- } catch (WrappedException we) {
- Logger.getLogger().logError(we);
- Logger.getLogger().logError(we.getMessage());
- if (we.getCause() != null)
- Logger.getLogger().logError(we.getCause());
- if (we.getNestedException() != null)
- Logger.getLogger().logError(we.getNestedException());
- if (we.getNestedException() != null)
- Logger.getLogger().logError(we.getConcatenatedMessages());
- throw we;
- }
- }
-
- /*public void testReadInitParms13() throws Exception {
- readInitParms(true);
- }
- public void testReadInitParms14() throws Exception{
- readInitParms(false);
- } */
-
- /*public void readInitParms(boolean is13) throws Exception {
- try {
- System.out.println("Using J2EE " + (is13?"1.3" :"1.4") );
- ArchiveOptions options = new ArchiveOptions();
- options.setRendererType(ArchiveOptions.DOM);
- final String earPath = AutomatedBVT.baseDirectory
- + ((is13) ? "filter13war.ear" : "servlet_js_filter.ear");
- CommonarchivePackage pkg = CommonarchivePackage.eINSTANCE;
- EARFile earFile = pkg.getCommonarchiveFactory().openEARFile(
- options, earPath);
- WARFile warFile = (WARFile) (is13 ? earFile.getFile("FilterWar.war") :earFile.getFile("servlet_js_filter_web.war"));
- WebApp webapp = warFile.getDeploymentDescriptor();
- assertNotNull("The web app DD could not be located", webapp);
- EList filters = webapp.getFilters();
- Filter f = null;
- EList parms, paramValues;
- for(int i=0; i<filters.size(); i++) {
- f = (Filter) filters.get(i);
- System.out.println(f);
- EList parms = f.getInitParams();
- System.out.println("There are " + parms.size() + " InitParams");
- for(int j=0; j<parms.size(); j++) {
- InitParam p = (InitParam) parms.get(j);
- System.out.println(p);
- }
- EList paramValues = f.getInitParamValues();
- System.out.println("There are " + paramValues.size() + " InitParamValues");
- for(int j=0; j<paramValues.size(); j++) {
- ParamValue p = (ParamValue) paramValues.get(j);
- System.out.println(p);
- }
-
- System.out.println("Demo version case");
-
-
- WebApp container = (WebApp) f.eContainer();
- switch(container.getJ2EEVersionID()) {
- case J2EEVersionConstants.J2EE_1_2_ID:
- case J2EEVersionConstants.J2EE_1_3_ID:
-
- parms = f.getInitParams();
- System.out.println("There are " + parms.size() + " InitParams");
- assertEquals("There must be 2 Filter Init Params", parms.size(), 2);
- for(int j=0; j<parms.size(); j++) {
- InitParam ip = (InitParam) parms.get(j);
- System.out.println(p);
- assertTrue("The param names much match", ("param"+j+"name").equals(ip.getParamName()));
- assertTrue("The param values much match", ("param"+j+"value").equals(ip.getParamValue()));
- }
- break;
- case J2EEVersionConstants.J2EE_1_4_ID: default: {
-
- paramValues = f.getInitParamValues();
- assertEquals("There must be 1 Filter Init Param Values", paramValues.size(), 1);
- System.out.println("There are " + paramValues.size() + " InitParamValues");
-
- ParamValue pv = (ParamValue) paramValues.get(0);
- System.out.println(pv);
- assertTrue("The param names much match", ("attribute").equals(pv.getName()));
- String expectedValue = (i == 0) ? "com.sun.ts.tests.servlet.api.javax_servlet.filter.DoFilter_Filter.SERVLET_MAPPED" : "com.sun.ts.tests.servlet.api.javax_servlet.filter.InitFilter_Filter.SERVLET_MAPPED";
- assertEquals("The param values much match", expectedValue , pv.getValue());
- }
- break;
- }
- }
-
-
- } catch (WrappedException we) {
- Logger.getLogger().logError(we);
- Logger.getLogger().logError(we.getMessage());
- if (we.getCause() != null)
- Logger.getLogger().logError(we.getCause());
- if (we.getNestedException() != null)
- Logger.getLogger().logError(we.getNestedException());
- if (we.getNestedException() != null)
- Logger.getLogger().logError(we.getConcatenatedMessages());
- throw we;
- }
- }*/
-
-
- private void printFiles(Container ar) {
- List files = ar.getFiles();
-
- for (int i = 0; i < files.size(); i++) {
- System.err.println(files.get(i));
- if (files.get(i) instanceof Container) {
- Container tainer = (Container) files.get(i);
- printFiles(tainer);
- }
- }
- }
-
-} \ No newline at end of file
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/DiscriminatorTest.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/DiscriminatorTest.java
deleted file mode 100644
index 734786d7..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/DiscriminatorTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package org.eclipse.jst.j2ee.archive.test;
-
-import java.io.File;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.ArchiveTypeDiscriminatorRegistry;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchiveFactory;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.GenericArchiveTypeDiscriminator;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-
-
-/*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2001, 2002 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- */
-
-/**
- * @author mdelder
- *
- */
-public class DiscriminatorTest
- extends TestCase {
-
- public boolean assertBarFile = false;
-
- public DiscriminatorTest(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite("DiscriminatorTest");
- suite.addTest(new DiscriminatorTest("testDiscriminator"));
- return suite;
- }
-
- // TODO Implement unit test for discriminator framework
- public void testDiscriminator() throws Exception {
- assertBarFile = true;
- try {
- ArchiveTypeDiscriminatorRegistry.registorDiscriminator(new BeverageArchiveDiscriminator());
- Archive archive = CommonarchiveFactory.eINSTANCE.openArchive( AutomatedBVT.baseDirectory + File.separator + "my.bar");
- assertNotNull("The archive was not found!", archive);
-
- assertTrue("The archive extension (.bar) was not recognized as a custom extension!", archive.isNestedArchive("my.bar"));
-
- boolean typeContributedSuccessfully = false;
- EList types = archive.getTypes();
- for (int i = 0; i < types.size(); i++) {
- if (types.get(i).equals(BeverageArchiveDiscriminator.BEVERAGE_ARCHIVE_TYPE_KEY)) {
- typeContributedSuccessfully = true;
- break;
- }
- }
- assertTrue("The BEVERAGE_ARCHIVE_TYPE_KEY was not found in the list of types of the archive!", typeContributedSuccessfully);
- } finally {
- assertBarFile = false;
- }
- }
-
- public class BeverageArchiveDiscriminator
- extends TestCase implements GenericArchiveTypeDiscriminator {
-
- public static final String BEVERAGE_ARCHIVE_TYPE_KEY = "com.ibm.beverage.archive";
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.j2ee.commonarchivecore.GenericArchiveTypeDiscriminator#discriminate(com.ibm.etools.j2ee.commonarchivecore.Archive)
- */
- public boolean discriminate(Archive anArchive) {
- boolean result = anArchive.containsFile("META-INF/adult-beverage-imbibement-options.xml");
- if (assertBarFile)
- assertTrue(
- "The BeverageArchiveDiscriminator did not recogniZe the file! (Ensure it contains a file named META-INF/adult-beverage-imbibement-venues.xml)",
- result);
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.j2ee.commonarchivecore.GenericArchiveTypeDiscriminator#getCustomFileExtensions()
- */
- public String[] getCustomFileExtensions() {
-
- return new String[] { "bar"};
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.j2ee.commonarchivecore.GenericArchiveTypeDiscriminator#getTypeKey()
- */
- public String getTypeKey() {
-
- return BEVERAGE_ARCHIVE_TYPE_KEY;
- }
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/DomComparitor.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/DomComparitor.java
deleted file mode 100644
index 454c1e30..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/DomComparitor.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * Created on Mar 17, 2003
- *
- * To change this generated comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.jst.j2ee.archive.test;
-
-import java.util.HashSet;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.CharacterData;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.ProcessingInstruction;
-import org.xml.sax.EntityResolver;
-
-/**
- * THE MASTER COPY of this class is in com.ibm.etools.commontests
- * Please update the copy in commontests and then copy this class to
- * where you need it if you are looking at a different copy
- *
- * @author jsholl
- *
- * To change this generated comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class DomComparitor {
- private static EntityResolver entityResolver;
- private static HashSet attributeList;
-// TODO replace this with non xerces
-// public static String compareDoms(InputSource source1, InputSource source2, HashSet ignorableAtts) throws Exception {
-// attributeList = ignorableAtts;
-// DOMParser parser = new DOMParser();
-// if (entityResolver == null) {
-// parser.setEntityResolver(new EntityResolver() {
-// public InputSource resolveEntity(String arg0, String arg1) throws SAXException, IOException {
-// return null;
-// }
-//
-// });
-// } else {
-// parser.setEntityResolver(entityResolver);
-// }
-// parser.parse(source1);
-// Document doc1 = parser.getDocument();
-// parser.parse(source2);
-// Document doc2 = parser.getDocument();
-// return compareNodes(doc1, doc2);
-// }
-
-// public static String compareDoms(InputSource source1, InputSource source2) throws Exception {
-// return compareDoms(source1, source2, null);
-// }
-
-
- public static String compareNodes(Node node1, Node node2) throws Exception {
- // System.out.println("checking A:" + node1);
- // System.out.println("checking B:" + node2);
- // System.out.println("nodeType=" + node1.getNodeType());
- // System.out.println("getNodeName=" + node1.getNodeName());
- // System.out.println("getNodeValue=" + node1.getNodeValue());
-
- //Generic Node Testing
- if (node1 == null && node2 == null)
- return null;
- else if ((node1 != null && node2 == null) || node1 == null && node2 != null)
- return nullNodeEncountered(node1, node2);
- else if (node1.getNodeType() != node2.getNodeType()) {
- return mismatch("Node.getNodeType() " + node1.getNodeType() + " " + node2.getNodeType(), node1, node2);
- } else if (node1.getNodeName() != node2.getNodeName()) {
- return mismatch("Node.getNodeName() <" + node1.getNodeName() + "> <" + node2.getNodeName() + ">", node1, node2);
- } else if (!(node1.getNodeValue() == null && node2.getNodeValue() == null)) {
- if (node1.getNodeValue() == null) {
- return mismatch("Node.getNodeValue() node A is null", node1, node2);
- } else if (node2.getNodeValue() == null) {
- return mismatch("Node.getNodeValue() node B is null", node1, node2);
- } else if (!node1.getNodeValue().equals(node2.getNodeValue())) {
- return mismatch("Node.getNodeValue() <" + node1.getNodeValue() + "> <" + node2.getNodeValue() + ">", node1, node2);
- }
- } else if (node1.hasAttributes() != node2.hasAttributes()) {
- return mismatch("Node.hasAttributes() " + node1.hasAttributes() + " " + node2.hasAttributes(), node1, node2);
- } else if (node1.hasChildNodes() != node2.hasChildNodes()) {
- return mismatch("Node.hasChildNodes() " + node1.hasChildNodes() + " " + node2.hasChildNodes(), node1, node2);
- }
- //TODO strengthen node comparisons as necessary
- //Specialized Node Testing
- switch (node1.getNodeType()) {
- case Node.TEXT_NODE :
- case Node.CDATA_SECTION_NODE :
- CharacterData cdata1 = (CharacterData) node1;
- CharacterData cdata2 = (CharacterData) node2;
- if (!cdata1.getData().equals(cdata2.getData())) {
- return mismatch("CharacterData.getData() " + cdata1.getData() + " " + cdata2.getData(), node1, node2);
- }
- break;
- case Node.ATTRIBUTE_NODE :
- Attr attr1 = (Attr) node1;
- Attr attr2 = (Attr) node2;
- if (!attr1.getName().equals(attr2.getName())) {
- return mismatch("Attr.getName() " + attr1.getName() + " " + attr2.getName(), node1, node2);
- }
- else if( attributeList != null && !attributeList.contains(attr1.getName()) && !attributeList.contains(attr2.getName())) {
- if (!attr1.getValue().equals(attr2.getValue())) {
- return mismatch("Attr.getValue() " + attr1.getValue() + " " + attr2.getValue(), node1, node2);
- } else if (attr1.getSpecified() != attr2.getSpecified()) {
- return mismatch("Attr.getSpecified() " + attr1.getSpecified() + " " + attr2.getSpecified(), node1, node2);
- }
- }
- break;
- case Node.DOCUMENT_NODE :
- Document doc1 = (Document)node1;
- Document doc2 = (Document)node2;
- String result = compareNodes(doc1.getDoctype(), doc2.getDoctype());
- if(result != null){
- return result;
- }
- break;
- case Node.DOCUMENT_TYPE_NODE:
- DocumentType docType1 = (DocumentType)node1;
- DocumentType docType2 = (DocumentType)node2;
- if(!docType1.getPublicId().equals(docType2.getPublicId())){
- return mismatch("DocumentType.getPublicId() "+docType1.getPublicId()+ " "+docType2.getPublicId(), node1, node2);
- }
- break;
- case Node.PROCESSING_INSTRUCTION_NODE :
- ProcessingInstruction pInst1 = (ProcessingInstruction)node1;
- ProcessingInstruction pInst2 = (ProcessingInstruction)node2;
- //System.out.println("ProcessingInstruction todo");
- break;
- case Node.DOCUMENT_FRAGMENT_NODE :
- DocumentFragment frag1 = (DocumentFragment)node1;
- DocumentFragment frag2 = (DocumentFragment)node2;
- //System.out.println("DocumentFragment todo");
- break;
-
- case Node.ELEMENT_NODE :
- case Node.COMMENT_NODE :
- case Node.ENTITY_NODE :
- case Node.NOTATION_NODE :
- break;
-
- }
-
- //Recursion
- NamedNodeMap attributes1 = node1.getAttributes();
- NamedNodeMap attributes2 = node2.getAttributes();
-
- if (attributes1 != null && attributes2 != null) {
- if (attributes1.getLength() != attributes2.getLength()) {
- return mismatch("getAttributes().getLength() " + attributes1.getLength() + " " + attributes2.getLength(), node1, node2);
- }
- for (int i = 0; i < attributes1.getLength(); i++) {
- Attr attr1 = (Attr) attributes1.item(i);
- Attr attr2 = (Attr) attributes2.item(i);
- if(!attr1.getName().equals(attr2.getName())){
- return mismatch("Attr.getName() " + attr1.getName() + " " + attr2.getName(), attr1, attr2);
- }
- if(attributeList != null && !attributeList.contains(attr1.getName()) && !attributeList.contains(attr2.getName())) {
- String results = compareNodes(attr1, attr2);
- if (null != results) {
- return results;
- }
- }
- }
-
- } else if (attributes1 != null || attributes2 != null) {
- return mismatch("getAttributes() null", node1, node2);
- }
-
- NodeList children1 = node1.getChildNodes();
- NodeList children2 = node2.getChildNodes();
-
- // if (children1.getLength() != children2.getLength()) {
- // return mismatch("getChildNodes().getLength() "+children1.getLength()+" "+children2.getLength(), node1, node2);
- // }
-
- int count1 = 0;
- int count2 = 0;
-
- //compare all children, skipping empty text nodes
- while (count1 < children1.getLength() && count2 < children2.getLength()) {
- Node child1 = children1.item(count1);
- Node child2 = children2.item(count2);
- if (child1.getNodeType() != child2.getNodeType()) {
- if (child1.getNodeType() == Node.TEXT_NODE && (child1.getNodeValue() == null || child1.getNodeValue().trim().equals(""))) {
- count1++;
- continue;
- } else if (child2.getNodeType() == Node.TEXT_NODE && (child2.getNodeValue() != null || child2.getNodeValue().trim().equals(""))) {
- count2++;
- continue;
- }
- }
- count1++;
- count2++;
- String results = compareNodes(child1, child2);
- if (null != results) {
- return results;
- }
- }
- //TODO there must be a way to tell the parser to ignore whitespace.
- //be sure skip any empty text nodes at the end
- while (count1 < children1.getLength()) {
- Node child1 = children1.item(count1);
- if (child1.getNodeType() == Node.TEXT_NODE && child1.getNodeValue() == null || child1.getNodeValue().trim().equals("")) {
- count1++;
- continue;
- }
- return nodeNotCompared(child1);
- }
-
- while (count2 < children2.getLength()) {
- Node child2 = children2.item(count2);
- if (child2.getNodeType() == Node.TEXT_NODE && child2.getNodeValue() == null || child2.getNodeValue().trim().equals("")) {
- count2++;
- continue;
- }
- return nodeNotCompared(child2);
- }
-
- // for (int i = 0; i < children1.getLength(); i++) {
- // Node child1 = children1.item(i);
- // Node child2 = children2.item(i);
- // }
-
- return null;
- }
-
-
- public static String nullNodeEncountered(Node node1, Node node2) {
- String message = "Null node encountered";
- Node nonNullNode = node1 == null ? node2 : node1;
- char source = node1 == null ? 'B' : 'A';
- while (nonNullNode != null) {
- message += source + nonNullNode.getNodeName() + "\n";
- nonNullNode = nonNullNode.getParentNode();
- }
- return message;
-
-
- }
-
- public static String nodeNotCompared(Node node) {
- String message = "Node node compared:";
- while (node != null) {
- message += node.getNodeName() + "\n";
- node = node.getParentNode();
- }
-
- return message;
- }
-
- public static String mismatch(String mismatchtype, Node node1, Node node2) throws Exception {
- String message = "Nodes A and B do not match because of node." + mismatchtype + "\n";
- while (node1 != null && node2 != null) {
- message += "A:" + node1.getNodeName() + "\n";
- message += "B:" + node2.getNodeName() + "\n";
- node1 = node1.getParentNode();
- node2 = node2.getParentNode();
- }
-
- return message;
- }
-
- public static void main(String[] args) {
- }
- /**
- * @return
- */
- public static EntityResolver getEntityResolver() {
- return entityResolver;
- }
-
- /**
- * @param resolver
- */
- public static void setEntityResolver(EntityResolver resolver) {
- entityResolver = resolver;
- }
-
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/InitializationTests.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/InitializationTests.java
deleted file mode 100644
index 354c4f88..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/InitializationTests.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package org.eclipse.jst.j2ee.archive.test;
-
- /*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2001 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- */
-
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-
-import org.eclipse.jst.j2ee.commonarchivecore.internal.ApplicationClientFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchiveFactory;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchivePackage;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EJBJarFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EJBModuleRef;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.WARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.WebModuleRef;
-/**
- * Insert the type's description here.
- * Creation date: (12/18/00 7:41:39 PM)
- * @author: Administrator
- */
-public class InitializationTests extends TestCase {
- private final static String copyright = "(c) Copyright IBM Corporation 2001.";//$NON-NLS-1$
-/**
- * InitializationTests constructor comment.
- * @param name java.lang.String
- */
-public InitializationTests(String name) {
- super(name);
-}
-public CommonarchiveFactory getArchiveFactory() {
- return CommonarchivePackage.eINSTANCE.getCommonarchiveFactory();
-}
-/**
- * Starts the application.
- * @param args an array of command-line arguments
- */
-public static void main(java.lang.String[] args) {
- String[] className = {"com.ibm.etools.archive.test.InitializationTests", "-noloading"};
- TestRunner.main(className);
-}
-public static junit.framework.Test suite() {
- return new TestSuite(InitializationTests.class);
-}
-public void testNewArchives() throws Exception {
-
-// Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
- ApplicationClientFile clientFile = getArchiveFactory().createApplicationClientFileInitialized("foo");
- assertTrue(clientFile.getDeploymentDescriptor() != null);
-
-
- clientFile = getArchiveFactory().createApplicationClientFileInitialized("foo");
-
- EJBJarFile ejbJarFile = getArchiveFactory().createEJBJarFileInitialized("foo");
- assertTrue(ejbJarFile.getDeploymentDescriptor() != null);
-
- //The next piece is to verify no exceptions occur
- ejbJarFile = getArchiveFactory().createEJBJarFileInitialized("foo");
- EJBModuleRef ejbModuleRef = getArchiveFactory().createEJBModuleRef();
- ejbModuleRef.setModuleFile(ejbJarFile);
-
-
- EARFile earFile = getArchiveFactory().createEARFileInitialized("foo");
-
- assertTrue(earFile.getDeploymentDescriptor() != null);
-
-
- WARFile warFile = getArchiveFactory().createWARFileInitialized("foo");
-
- assertTrue(warFile.getDeploymentDescriptor() != null);
-
-
- warFile = getArchiveFactory().createWARFileInitialized("foo");
- WebModuleRef webModuleRef = getArchiveFactory().createWebModuleRef();
- webModuleRef.setModuleFile(warFile);
-
-
-}
-
-
-
-
-
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/JavaTests.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/JavaTests.java
deleted file mode 100644
index 7133bd86..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/JavaTests.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package org.eclipse.jst.j2ee.archive.test;
-
- /*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2001 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- */
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchiveFactory;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchivePackage;
-/**
- * Insert the type's description here.
- * Creation date: (1/17/2001 10:17:29 AM)
- * @author: Administrator
- */
-public class JavaTests extends TestCase {
- private final static String copyright = "(c) Copyright IBM Corporation 2001.";//$NON-NLS-1$
-/**
- * JavaTests constructor comment.
- * @param name java.lang.String
- */
-public JavaTests(String name) {
- super(name);
-}
-public CommonarchiveFactory getArchiveFactory() {
- return CommonarchivePackage.eINSTANCE.getCommonarchiveFactory();
-}
-/**
- * Starts the application.
- * @param args an array of command-line arguments
- */
-public static void main(java.lang.String[] args) {
- String[] className = {"com.ibm.etools.archive.test.JavaTests", "-noloading"};
- TestRunner.main(className);
-}
-public static junit.framework.Test suite() {
- return new TestSuite(JavaTests.class);
-}
-/**
- * This method verifies that java reflection works on archives, and that
- * class loading and java reflection is dynamic with changes to the class
- * path of the archive
- */
-public void testJavaReflection() throws Exception {
-/*
- Archive anArchive = getArchiveFactory().primOpenArchive("bank35deployed.jar");
- JavaClass cls = (JavaClass)org.eclipse.jem.internal.java.impl.JavaClassImpl.reflect("com.ibm.ejb.bank.VapAccountBean", anArchive.getContext());
- //Ignore the constructor
- assertTrue("Should not have been able to reflect methods" ,cls.getMethods().size() == 1 && ((Method)cls.getMethods().get(0)).getName().equals(cls.getName()));
-
- anArchive.setExtraClasspath("ivjejb35.jar");
-
- assertTrue("Methods should have been reflected", cls.getMethods().size() > 1);
-*/
-}
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/LooseArchiveTests.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/LooseArchiveTests.java
deleted file mode 100644
index ffeb37a5..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/LooseArchiveTests.java
+++ /dev/null
@@ -1,282 +0,0 @@
-package org.eclipse.jst.j2ee.archive.test;
-
-
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.jst.j2ee.application.Module;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.File;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.ModuleRef;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveInit;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.RuntimeClasspathEntry;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil;
-import org.eclipse.jst.j2ee.commonarchivecore.looseconfig.internal.LooseApplication;
-import org.eclipse.jst.j2ee.commonarchivecore.looseconfig.internal.LooseConfigRegister;
-import org.eclipse.jst.j2ee.commonarchivecore.looseconfig.internal.LooseConfiguration;
-import org.eclipse.jst.j2ee.commonarchivecore.looseconfig.internal.LooseLibrary;
-import org.eclipse.jst.j2ee.commonarchivecore.looseconfig.internal.LooseModule;
-import org.eclipse.jst.j2ee.commonarchivecore.looseconfig.internal.LooseWARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.looseconfig.internal.LooseconfigFactory;
-import org.eclipse.jst.j2ee.commonarchivecore.looseconfig.internal.LooseconfigPackage;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-
-
-public class LooseArchiveTests extends AbstractArchiveTest {
-
- /** The current working directory */
- protected String cwd;
- protected URI looseConfigLoc;
- protected URI looseAppLoc;
- protected String looseModuleWorkspace;
- protected String looseEARUri;
-
- protected static final String EJB_JAR_URI = "LooseEAREjb.jar";
- protected static final String WAR_URI = "LooseEARWeb.war";
- protected static final String UTIL_JAR_URI = "util.jar";
- protected static final String WEBLIB_URI = "WEB-INF/lib/library.jar";
- protected static final String WEBLIB_FULL_URI = "WEB-INF/lib/library.jar";
- protected static final String OUTPUT_EAR_FILE_URI = AutomatedBVT.baseDirectory +"testOutput/LooseArchiveTests/LooseApp.ear";
- protected static char sep = java.io.File.separatorChar;
- /**
- * Constructor for LooseArchiveTests.
- * @param name
- */
- public LooseArchiveTests(String name) {
- super(name);
- }
-
- public void testLooseConfigCreation() throws Exception {
- Resource resource = Resource.Factory.Registry.INSTANCE.getFactory(looseConfigLoc).createResource(looseConfigLoc);
- resource.getContents().add(createLooseConfig());
- resource.save(new java.util.HashMap());
- }
-
- public void testLooseAppCreation() throws Exception {
- Resource resource = Resource.Factory.Registry.INSTANCE.getFactory(looseAppLoc).createResource(looseAppLoc);
- resource.getContents().add(createLooseApplication());
- resource.save(new java.util.HashMap());
- }
-
- public void testLooseConfigOpenAndSave() throws Exception {
- System.setProperty(LooseConfigRegister.LOOSE_CONFIG_PROPERTY, looseConfigLoc.toString());
- EARFile ear = getArchiveFactory().openEARFile(looseEARUri);
- verify(ear);
- //printClasspaths(ear);
- ear.saveAs(OUTPUT_EAR_FILE_URI);
- ear.close();
- ear = getArchiveFactory().openEARFile(OUTPUT_EAR_FILE_URI);
- verify(ear);
- ear.close();
-
- }
-
-
-
- public void testLooseConfigUnimodeOpenAndSave() throws Exception {
- System.setProperty(LooseConfigRegister.LOOSE_CONFIG_PROPERTY, "");
-
- LooseConfigRegister.singleton().addLooseMapping(looseEARUri, looseAppLoc.toString());
- EARFile ear = getArchiveFactory().openEARFile(looseEARUri);
- verify(ear);
- //printClasspaths(ear);
- ear.saveAs(OUTPUT_EAR_FILE_URI);
- ear.close();
-
- ear = getArchiveFactory().openEARFile(OUTPUT_EAR_FILE_URI);
- verify(ear);
- ear.close();
-
- }
-
- public void testLooseConfigOpenAndReOpen() throws Exception {
- System.setProperty(LooseConfigRegister.LOOSE_CONFIG_PROPERTY, looseConfigLoc.toString());
- EARFile ear = getArchiveFactory().openEARFile(looseEARUri);
- ear.close();
- ear.reopen();
- List jars = ear.getArchiveFiles();
- for (int i = 0; i < jars.size(); i++) {
- Archive archive = (Archive) jars.get(i);
- archive.close();
- archive.reopen(ear);
- }
- ear.close();
-
- }
-
- protected void verify(EARFile ear) throws Exception {
- verifyModules(ear);
- verifyModuleRefs(ear);
- verifyUtilAndLib(ear);
- }
-
- /**
- * Another level of verification that for each module, the module files exists
- * and the deployment descriptor can be read
- */
- protected void verifyModuleRefs(EARFile ear) throws Exception {
- List moduleRefs = ear.getModuleRefs();
- int size = moduleRefs.size();
- assertEquals("Wrong number of modules", 2, size);
- for (int i = 0; i < size; i++) {
- ModuleRef ref = (ModuleRef) moduleRefs.get(i);
- assertNotNull("ModuleRef should have a module file:"+ref.getModule().getUri(), ref.getModuleFile());
- assertNotNull("Deployment descriptor should not be null", ref.getDeploymentDescriptor());
- }
- }
-
- /**
- * Verify that the util jar in the ear and the library in the war exist and are not empty
- */
- protected void verifyUtilAndLib(EARFile ear) throws Exception {
- verifyJAR(ear, UTIL_JAR_URI);
- verifyJAR((Archive)ear.getFile(WAR_URI), WEBLIB_FULL_URI);
-
- }
-
- protected void verifyJAR(Archive parent, String uri) throws Exception {
- assertTrue("Should contain JAR: "+uri, parent.containsFile(uri));
- Archive jar = (Archive)parent.getFile(uri);
- //at lease one file plus the manifest
- assertTrue("JAR should contain a class file: "+uri, containsClassFile(jar));
- }
-
- protected boolean containsClassFile(Archive jar) {
- List files = jar.getFiles();
- for (int i = 0; i < files.size(); i++) {
- File aFile = (File) files.get(i);
- if (aFile.getURI().endsWith(".class"));
- return true;
- }
- return false;
- }
-
- /**
- * Make sure {@link Container#containsFile(String) works for loose modules
- */
- public void verifyModules(EARFile ear) throws Exception {
- List modules = ear.getDeploymentDescriptor().getModules();
- int size = modules.size();
- for (int i = 0; i < modules.size(); i++) {
- Module m = (Module) modules.get(i);
- assertTrue("EAR file should contain module file: "+m.getUri(), ear.containsFile(m.getUri()));
- }
- assertEquals("Wrong number of modules", 2, size);
- for (int i = 0; i < modules.size(); i++) {
- Module m = (Module) modules.get(i);
- assertTrue("EAR file should contain module file: "+m.getUri(), ear.containsFile(m.getUri()));
- }
- }
-
- protected LooseConfiguration createLooseConfig() {
- LooseConfiguration config = looseConfigFactory().createLooseConfiguration();
- config.getApplications().add(createLooseApplication());
- return config;
- }
-
- protected LooseApplication createLooseApplication() {
- LooseApplication app = looseConfigFactory().createLooseApplication();
- app.setUri(looseEARUri);
- app.setResourcesPath(looseEARUri);
- app.setBinariesPath(looseEARUri);
- List looseArchives = app.getLooseArchives();
- looseArchives.add(createLooseEJB());
- looseArchives.add(createLooseWEB());
- looseArchives.add(createLooseUtil());
- return app;
- }
-
- protected LooseModule createLooseEJB() {
- LooseModule mod = looseConfigFactory().createLooseModule();
- mod.setUri(EJB_JAR_URI);
- String absPath = looseModuleWorkspace+sep+"LooseEAREjb"+sep+"bin";
- mod.setBinariesPath(absPath);
- mod.setResourcesPath(absPath);
- return mod;
- }
-
- protected LooseModule createLooseWEB() {
- LooseWARFile mod = looseConfigFactory().createLooseWARFile();
- mod.setUri(WAR_URI);
- String absPath = looseModuleWorkspace+sep+"LooseEARWeb"+sep+"webApplication";
- mod.setBinariesPath(absPath);
- mod.setResourcesPath(absPath);
- mod.getLooseLibs().add(createLooseWebLib());
- return mod;
- }
-
- protected LooseLibrary createLooseUtil() {
- LooseLibrary lib = looseConfigFactory().createLooseLibrary();
- lib.setUri(UTIL_JAR_URI);
- String absPath = looseModuleWorkspace+sep+"LooseJavaUtil"+sep+"bin";
- lib.setBinariesPath(absPath);
- lib.setResourcesPath(absPath);
- return lib;
- }
-
- protected LooseLibrary createLooseWebLib() {
- LooseLibrary lib = looseConfigFactory().createLooseLibrary();
- lib.setUri(WEBLIB_URI);
- String absPath = looseModuleWorkspace+sep+"LooseJavaWebLib"+sep+"bin";
- lib.setBinariesPath(absPath);
- lib.setResourcesPath(absPath);
- return lib;
- }
-
- protected LooseconfigFactory looseConfigFactory() {
- return LooseconfigPackage.eINSTANCE.getLooseconfigFactory();
- }
-
- protected void printClasspaths(EARFile ear) {
- List archives = ear.getArchiveFiles();
- for (int i = 0; i < archives.size(); i++) {
- Archive archive = (Archive) archives.get(i);
- System.out.println("Local runtime classpath for: "+archive.getURI());
- RuntimeClasspathEntry[] entries = archive.getLocalRuntimeClassPath();
- for (int j = 0; j < entries.length; j++) {
- System.out.println(entries[j]);
- }
- System.out.println("Full runtime classpath for: "+archive.getURI());
- entries = archive.getFullRuntimeClassPath();
- for (int j = 0; j < entries.length; j++) {
- System.out.println(entries[j]);
- }
- }
- }
-
-
- public static void main(String[] args) {
- String[] className = { "com.ibm.etools.archive.test.LooseArchiveTests", "-noloading" };
- TestRunner.main(className);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite("LooseArchiveTests");
- suite.addTest(new LooseArchiveTests("testLooseConfigCreation"));
- suite.addTest(new LooseArchiveTests("testLooseAppCreation"));
- suite.addTest(new LooseArchiveTests("testLooseConfigOpenAndSave"));
- suite.addTest(new LooseArchiveTests("testLooseConfigOpenAndReOpen"));
- suite.addTest(new LooseArchiveTests("testLooseConfigUnimodeOpenAndSave"));
- return suite;
- }
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- ArchiveInit.init();
- LooseConfigRegister.singleton().flush();
- cwd = AutomatedBVT.baseDirectory;
- looseModuleWorkspace = cwd+"loose_module_workspace";
- looseConfigLoc = URI.createFileURI(looseModuleWorkspace+sep+".metadata"+sep+".plugins"+sep+"com.ibm.etools.j2ee"+sep+"looseConfig.xmi");
- looseAppLoc = URI.createFileURI(looseModuleWorkspace+sep+".metadata"+sep+".plugins"+sep+"com.ibm.etools.j2ee"+sep+"looseApp.xmi");
- looseEARUri = ArchiveUtil.getOSUri(looseModuleWorkspace+sep+"LooseEAR");
- }
-
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/RarFileTests.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/RarFileTests.java
deleted file mode 100644
index d5358d2d..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/RarFileTests.java
+++ /dev/null
@@ -1,207 +0,0 @@
-package org.eclipse.jst.j2ee.archive.test;
-
-/*
-* Licensed Material - Property of IBM
-* (C) Copyright IBM Corp. 2001 - All Rights Reserved.
-* US Government Users Restricted Rights - Use, duplication or disclosure
-* restricted by GSA ADP Schedule Contract with IBM Corp.
-*/
-
-import java.util.List;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchiveFactory;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchivePackage;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.RARFile;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-import org.eclipse.jst.j2ee.jca.AuthenticationMechanism;
-import org.eclipse.jst.j2ee.jca.ConfigProperty;
-import org.eclipse.jst.j2ee.jca.Connector;
-import org.eclipse.jst.j2ee.jca.ResourceAdapter;
-import org.eclipse.jst.j2ee.jca.SecurityPermission;
-
-/**
- * Tests for verfication that RAR support works correctly in WCCM.
- * Creation date: (12/11/00 10:26:11 AM)
- * @author: Jared Jurkiewicz, et al.
- */
-public class RarFileTests extends TestCase {
- private final static String copyright = "(c) Copyright IBM Corporation 2001."; //$NON-NLS-1$
- /**
- * SimpleTests constructor comment.
- * @param name java.lang.String
- */
- public RarFileTests(String name) {
- super(name);
- }
- public CommonarchiveFactory getArchiveFactory() {
- return CommonarchivePackage.eINSTANCE.getCommonarchiveFactory();
- }
- /**
- * Starts the application.
- * @param args an array of command-line arguments
- */
- public static void main(java.lang.String[] args) {
- String[] className = { "com.ibm.etools.archive.test.RarFileTests", "-noloading" };
- TestRunner.main(className);
- }
- public void printRARToConsole(Connector connector) {
- ResourceAdapter ra = connector.getResourceAdapter();
-
- System.out.println("ResourceAdapter from XML Deployment Descriptor");
- System.out.println("-------------------------------------------------");
- System.out.println(connector.getDisplayName() + ": " + connector.getDescription());
- System.out.println("Vendor : " + connector.getVendorName());
- System.out.println("Version : " + connector.getVersion());
- System.out.println("Spec Version : " + connector.getSpecVersion());
- System.out.println("EIS Type : " + connector.getEisType());
- System.out.println("Reauthentication Support : " + ra.isReauthenticationSupport());
- System.out.println("Transaction Support : " + ra.getTransactionSupport().getName().toLowerCase());
-
- if (connector.getLicense() != null) {
- System.out.println("License Required : " + connector.getLicense().isRequired());
- System.out.println("License Description : " + connector.getLicense().getDescription());
- }
-
- System.out.println("Small Icon : " + connector.getSmallIcon());
- System.out.println("Large Icon : " + connector.getLargeIcon());
-
- List authMechs = ra.getAuthenticationMechanisms();
- for (int i = 0; i < authMechs.size(); i++) {
- AuthenticationMechanism auth = (AuthenticationMechanism) authMechs.get(i);
- System.out.println("\nAuthentication Mechanism:");
- System.out.println("Description : " + auth.getDescription());
- System.out.println("Type : " + auth.getAuthenticationMechanismType().getName().toLowerCase());
- System.out.println("Credential Interface : " + auth.getCredentialInterface());
- }
- System.out.println("\nRegistered classes:");
- System.out.println("\t" + ra.getConnectionFactoryImplClass() + " implements ");
- System.out.println("\t\t" + ra.getConnectionFactoryInterface());
- System.out.println("\t" + ra.getConnectionImplClass() + " implements ");
- System.out.println("\t\t" + ra.getConnectionInterface());
- System.out.println("\tManagedConnectionFactory: " + ra.getManagedConnectionFactoryClass());
-
- List configs = ra.getConfigProperties();
- System.out.println("\nConfig-properties:");
- for (int i = 0; i < configs.size(); i++) {
- ConfigProperty prop = (ConfigProperty) configs.get(i);
- System.out.println("\tConfig-property : " + prop.getName());
- System.out.println("\tType : " + prop.getType() + " / Value : " + prop.getValue());
- System.out.println("\tDescription : " + prop.getDescription() + "\n");
- }
-
- List secs = ra.getSecurityPermissions();
- System.out.println("\nSecurity-Permissions:");
- for (int i = 0; i < secs.size(); i++) {
- SecurityPermission prop = (SecurityPermission) secs.get(i);
- System.out.println("\tConfig-Description : " + prop.getDescription());
- System.out.println("\tSpecification : " + prop.getSpecification() + "\n");
- }
-
- }
- public static junit.framework.Test suite() {
- return new TestSuite(RarFileTests.class);
- }
- public void testaddCopyModule() throws Exception {
-
- String in = AutomatedBVT.baseDirectory + "sample.rar";
- RARFile rarFile = (RARFile) getArchiveFactory().openArchive(in);
-
- rarFile.getDeploymentDescriptor();
-
- EARFile newEarFile = getArchiveFactory().createEARFileInitialized(AutomatedBVT.baseDirectory + "testOutput/CopyTests/newEarWithRarCopiedModule.ear");
-
- newEarFile.addCopy(rarFile);
- RARFile copied = (RARFile) newEarFile.getModuleFiles().get(0);
- assertTrue(copied.isDeploymentDescriptorSet());
- assertTrue(copied.getDeploymentDescriptor() == copied.getDeploymentDescriptorResource().getContents().get(0));
- assertTrue(copied.getDeploymentDescriptor() != rarFile.getDeploymentDescriptor());
- assertTrue(rarFile.getFiles().size() == copied.getFiles().size());
-
- newEarFile.saveNoReopen();
- }
- public void testexpandRarModule() throws Exception {
-
- String in = AutomatedBVT.baseDirectory + "sample.rar";
- RARFile rarFile = (RARFile) getArchiveFactory().openArchive(in);
- rarFile.setURI("sample.rar");
-
- rarFile.getDeploymentDescriptor();
-
- EARFile newEarFile = getArchiveFactory().createEARFileInitialized(AutomatedBVT.baseDirectory + "testOutput/RarTests/newEarWithRarModule.ear");
- newEarFile.addCopy(rarFile);
-
- newEarFile.saveNoReopen();
-
- String out = AutomatedBVT.baseDirectory + "testOutput/RarTests/Rar-containing-ear-out.ear";
- newEarFile.extractTo(out, Archive.EXPAND_RAR_FILES);
- }
-
- /**
- * Very basic method to open an archive and save it as a directory to a new destination. Requires visual inspection
- * for verification. Nested wars and ejb jars will be exploded but other nested jars will not
- */
- public void testOpenAndExtract() throws Exception {
-
- String in = AutomatedBVT.baseDirectory + "sample.rar";
- RARFile rarFile = (RARFile) getArchiveFactory().openArchive(in);
- String out = AutomatedBVT.baseDirectory + "testOutput/Exploded_RAR_Dir/";
- rarFile.extractToConnectorDirectory(out, Archive.EXPAND_ALL);
- }
- /**
- * Opens an ear file, and for each module, writes it's dd components to the console. Requires visual inspection
- * for verification
- */
-
- public void testOpenAndRead() throws Exception {
-
- String in = AutomatedBVT.baseDirectory + "sample.rar";
- RARFile rarFile = (RARFile) getArchiveFactory().openArchive(in);
-
- Connector dd = rarFile.getDeploymentDescriptor();
- //printRARToConsole(dd);
- }
-
- public void testopenRarEar() throws Exception {
- EARFile earFile = (EARFile) getArchiveFactory().openArchive(AutomatedBVT.baseDirectory + "testrar.ear");
- assertTrue(earFile.getDeploymentDescriptor().getFirstModule("sample.rar") != null);
- }
-
- public void testSaveRarEar() throws Exception {
- String in = AutomatedBVT.baseDirectory + "sample.rar";
- RARFile rarFile = (RARFile) getArchiveFactory().openArchive(in);
- rarFile.setURI("sample.rar");
-
- rarFile.getDeploymentDescriptor();
-
- EARFile newEarFile = getArchiveFactory().createEARFileInitialized(AutomatedBVT.baseDirectory + "testOutput/RarTests/newEarWithRarModule_saved.ear");
- newEarFile.addCopy(rarFile);
-
- assertNotNull("Module wasn't found!", newEarFile.getDeploymentDescriptor().getFirstModule("sample.rar"));
-
- newEarFile.save();
- }
-
- public void testJ2Cauth() throws Exception {
- String in = AutomatedBVT.baseDirectory + "sample.rar";
- RARFile rarFile = (RARFile) getArchiveFactory().openArchive(in);
-
- Connector dd = rarFile.getDeploymentDescriptor();
-
- ResourceAdapter rd = dd.getResourceAdapter();
-
- EList myAuthList = rd.getAuthenticationMechanisms();
-// System.out.println("Number of auth mechanisms is: " + myAuthList.size());
-// for (int i = 0; i < myAuthList.size(); i++) {
-// System.out.println("Auth type is: " + ((AuthenticationMechanism) myAuthList.get(i)).getAuthenticationMechanismType());
-// System.out.println("Auth type is: " + ((AuthenticationMechanism) myAuthList.get(i)).getAuthenticationMechanismType().getName());
-// }
- }
-
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/ResourceTests.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/ResourceTests.java
deleted file mode 100644
index 29ca510a..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/ResourceTests.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Created on Mar 13, 2003
- *
- * To change this generated comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.jst.j2ee.archive.test;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.jst.j2ee.common.CommonPackage;
-import org.eclipse.jst.j2ee.common.EjbRef;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.ApplicationClientFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EJBJarFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveInit;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-
-
-/**
- * @author schacher
- *
- * To change this generated comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class ResourceTests extends AbstractArchiveTest {
-
- /**
- * @param name
- */
- public ResourceTests(String name) {
- super(name);
- }
-
- /**
- * Starts the application.
- * @param args an array of command-line arguments
- */
- public static void main(java.lang.String[] args) {
- String[] className = {"com.ibm.etools.archive.test.ResourceTests", "-noloading"};
- TestRunner.main(className);
- }
- public static junit.framework.Test suite() {
- return new TestSuite(ResourceTests.class);
- }
-
- protected List findOccurrences(List resources, String uri) {
- List result = new ArrayList(1);
- for (int i = 0; i < resources.size(); i++) {
- Resource aResource = (Resource) resources.get(i);
- if (uri.equals(aResource.getURI().toString()))
- result.add(aResource);
- }
- return result;
- }
-
- public void testResourceCreation() throws Exception {
- String uri = "META-INF/client-resource.xmi";
- ApplicationClientFile appClientFile = getArchiveFactory().createApplicationClientFileInitialized("test.jar");
- Resource res = null;
- boolean exceptionCaught = false;
- try {
- res = appClientFile.getMofResource(uri);
- } catch (java.io.FileNotFoundException e) {
- exceptionCaught = true;
- List foundResources = findOccurrences(appClientFile.getResourceSet().getResources(), uri);
- assertTrue("There should exist exactly one resource", foundResources.size() == 1);
- Resource foundResource = (Resource)foundResources.get(0);
- assertFalse("The resource should be unloaded", foundResource.isLoaded());
- res = appClientFile.makeMofResource(uri);
- assertTrue("Resource should not be null", res != null);
- foundResources = findOccurrences(appClientFile.getResourceSet().getResources(), uri);
- assertTrue("There should exist exactly one resource", foundResources.size() == 1);
- foundResource = (Resource)foundResources.get(0);
- assertTrue("The resource should exist", foundResource != null);
- assertFalse("The resource should be unloaded", foundResource.isLoaded());
- }
- assertTrue("Exception should have been caught", exceptionCaught);
- Collection loadedResources = appClientFile.getLoadedMofResources();
- assertTrue("Loaded resources should be size 1", loadedResources.size() == 1);
- EjbRef aRef = CommonPackage.eINSTANCE.getCommonFactory().createEjbRef();
- res.getContents().add(aRef);
- loadedResources = appClientFile.getLoadedMofResources();
- assertTrue("Loaded resources should be size 2", loadedResources.size() == 2);
- }
-
- public void testResourceDirty() throws Exception {
- EJBJarFile jar = getArchiveFactory().openEJB11JarFile(AutomatedBVT.baseDirectory + "bankejbs.jar");
- EnterpriseBean bean = (EnterpriseBean)jar.getDeploymentDescriptor().getEnterpriseBeans().get(0);
-
- EARFile newEar = getArchiveFactory().createEARFileInitialized("test");
- EJBJarFile copyJar = (EJBJarFile) newEar.addCopy(jar);
-
- assertFalse("dd should not be dirty", copyJar.getDeploymentDescriptorResource().isModified());
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- ArchiveInit.init();
- }
-
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/SaveTests.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/SaveTests.java
deleted file mode 100644
index 046c1167..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/SaveTests.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package org.eclipse.jst.j2ee.archive.test;
-
-/*
-* Licensed Material - Property of IBM
-* (C) Copyright IBM Corp. 2001 - All Rights Reserved.
-* US Government Users Restricted Rights - Use, duplication or disclosure
-* restricted by GSA ADP Schedule Contract with IBM Corp.
-*/
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchiveFactory;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchivePackage;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.File;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.ReadOnlyDirectory;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.WARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveConstants;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-
-/**
- * Insert the type's description here.
- * Creation date: (12/21/00 3:04:36 PM)
- * @author: Administrator
- */
-public class SaveTests extends TestCase {
- private final static String copyright = "(c) Copyright IBM Corporation 2001."; //$NON-NLS-1$
- /**
- * SaveTests constructor comment.
- * @param name java.lang.String
- */
- public SaveTests(String name) {
- super(name);
- }
- public CommonarchiveFactory getArchiveFactory() {
- return CommonarchivePackage.eINSTANCE.getCommonarchiveFactory();
- }
- /**
- * Starts the application.
- * @param args an array of command-line arguments
- */
- public static void main(java.lang.String[] args) {
- String[] className = { "com.ibm.etools.archive.test.SaveTests", "-noloading" };
- TestRunner.main(className);
- }
- public static junit.framework.Test suite() {
- return new TestSuite(SaveTests.class);
- }
- /**
- * This scenario tests the case of opening an archive, modifying it's contents, and saving to the same uri from which it was
- * loaded. The problem is that the reading of input streams of individual entries in an archive is deferred until requested through
- * the api or save time; therefore, an open file exists on the source file. To get around this, the implementation saves the archive
- * to a temp file, then deletes (or renames, based on setting, to be implemented) the old file, renames the temp file, and does some
- * housekeeping on the saved archive, with it's load strategy and contained files
- */
- public void testSave() throws Exception {
-
- //First make a copy of our reference file
- Archive anArchive = getArchiveFactory().openArchive(AutomatedBVT.baseDirectory + "example2.war");
- anArchive.saveAsNoReopen(AutomatedBVT.baseDirectory + "testOutput/SaveTests/copy.war");
- anArchive = null;
-
- WARFile aWarFile = (WARFile) getArchiveFactory().openArchive(AutomatedBVT.baseDirectory + "testOutput/SaveTests/copy.war");
- ReadOnlyDirectory sampleDirectory = getArchiveFactory().openReadOnlyDirectory(AutomatedBVT.baseDirectory + "WarTestClasses");
- int initialSize = aWarFile.getClasses().size();
- File aFile = sampleDirectory.getFileInSelfOrSubdirectory("com/ibm/etools/archive/test/WARFileTests.class");
- aWarFile.addCopyClass(aFile);
- assertTrue(aWarFile.getClasses().size() == initialSize + 1);
-
- String classURI = ArchiveUtil.concatUri(ArchiveConstants.WEBAPP_CLASSES_URI, aFile.getURI(), '/');
- assertTrue(aWarFile.containsFile(classURI));
- aWarFile.save();
-
- File classFile = aWarFile.getFile(classURI);
- assertTrue("File should not be null", classFile != null);
- assertTrue("Wrong loading archive", classFile.getLoadingContainer() == aWarFile);
- assertTrue("Wrong original URI", classFile.getOriginalURI().equals(classURI));
-
- aWarFile.saveAs("testOutput/SaveTests/copy2.war");
- aWarFile.save();
- }
-
- /**
- * This scenario is similar to @link #testSave, except that it tests with a directory instead of a jar file
- */
- public void testSaveDirectory() throws Exception {
-
- //First make a copy of our reference file
- Archive anArchive = getArchiveFactory().openArchive(AutomatedBVT.baseDirectory + "sample.ear");
- anArchive.saveAsNoReopen(AutomatedBVT.baseDirectory + "testOutput/SaveTests/sample-copied.ear");
- anArchive = null;
-
- EARFile anEARFile = (EARFile) getArchiveFactory().openArchive(AutomatedBVT.baseDirectory + "testOutput/SaveTests/sample-copied.ear");
-
- anEARFile.getDeploymentDescriptor();
-
-
- anEARFile.extractNoReopen(Archive.EXPAND_WAR_FILES);
-
- }
-
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/SecurityRoleTests.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/SecurityRoleTests.java
deleted file mode 100644
index 4ac0dc4c..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/SecurityRoleTests.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package org.eclipse.jst.j2ee.archive.test;
-
- /*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2001 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- */
-
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-
-import org.eclipse.jst.j2ee.common.CommonFactory;
-import org.eclipse.jst.j2ee.common.CommonPackage;
-import org.eclipse.jst.j2ee.common.SecurityRole;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EJBJarFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EJBModuleRef;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.WARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.WebModuleRef;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-
-/**
- * Insert the type's description here.
- * Creation date: (02/09/01 12:05:18 AM)
- * @author: Administrator
- */
-public class SecurityRoleTests extends AbstractArchiveTest {
- private final static String copyright = "(c) Copyright IBM Corporation 2001.";//$NON-NLS-1$
-/**
- * SecurityRoleTests constructor comment.
- * @param name java.lang.String
- */
-public SecurityRoleTests(String name) {
- super(name);
-}
-public CommonFactory getCommonFactory() {
- return CommonPackage.eINSTANCE.getCommonFactory();
-}
-/**
- * Starts the application.
- * @param args an array of command-line arguments
- */
-public static void main(java.lang.String[] args) {
- String[] className = {"com.ibm.etools.archive.test.SecurityRoleTests", "-noloading"};
- TestRunner.main(className);
-}
-public static junit.framework.Test suite() {
- return new TestSuite(SecurityRoleTests.class);
-}
-public void testPushDownCopy() throws Exception {
-
- EARFile earFile = getArchiveFactory().openEARFile(AutomatedBVT.baseDirectory + "sample.ear");
-
- WARFile warFile = (WARFile)earFile.getWARFiles().get(0);
-
- EJBJarFile ejbJarFile = (EJBJarFile) earFile.getEJBJarFiles().get(0);
-
- SecurityRole aRole = getCommonFactory().createSecurityRole();
- aRole.setRoleName("administrator");
- aRole.setDescription("The all powerful");
- earFile.getDeploymentDescriptor().getSecurityRoles().add(aRole);
- earFile.pushDownRole(aRole);
-
- assertTrue("Push down failed for ejb jar", ejbJarFile.getDeploymentDescriptor().getAssemblyDescriptor().getSecurityRoleNamed("administrator") != null);
- assertTrue("Push down failed for war", warFile.getDeploymentDescriptor().getSecurityRoleNamed("administrator") != null);
-
- earFile.close();
-
-}
-public void testRollupAddAndPushDown() throws Exception {
-
- EARFile earFile = getArchiveFactory().openEARFile(AutomatedBVT.baseDirectory +"sample.ear");
-
- WebModuleRef webRef = (WebModuleRef)earFile.getWebModuleRefs().get(0);
-
- EJBModuleRef ejbModRef = (EJBModuleRef) earFile.getEJBModuleRefs().get(0);
-
- SecurityRole aRole = getCommonFactory().createSecurityRole();
- aRole.setRoleName("Joe");
- aRole.setDescription("New description");
- webRef.getWebApp().getSecurityRoles().add(aRole);
-
- aRole = getCommonFactory().createSecurityRole();
- aRole.setRoleName("administrator");
- aRole.setDescription("The all powerful");
-
- webRef.getWebApp().getSecurityRoles().add(aRole);
-
- //Test the rollup
- earFile.rollUpRoles();
- //We cheated here because we already knew there were two roles in the ejb jar
- //one of which is named Joe, and zero roles in the war file
- assertTrue("Roll up not right", earFile.getDeploymentDescriptor().getSecurityRoles().size() == 5);
-
- aRole = getCommonFactory().createSecurityRole();
- aRole.setRoleName("manager");
- aRole.setDescription("the manager");
- earFile.addCopy(aRole, webRef.getModule());
-
- //Test the add and rollup
- assertTrue("Add copy not right", earFile.getDeploymentDescriptor().getSecurityRoles().size() == 6
- && earFile.getDeploymentDescriptor().containsSecurityRole(aRole.getRoleName())
- && webRef.getWebApp().containsSecurityRole(aRole.getRoleName()));
-
- //Test the push down
- earFile.renameSecurityRole("Joe", "guest");
-
- assertTrue("Push down not right", !earFile.getDeploymentDescriptor().containsSecurityRole("Joe")
- && earFile.getDeploymentDescriptor().containsSecurityRole("guest")
- && !webRef.getWebApp().containsSecurityRole("Joe")
- && webRef.getWebApp().containsSecurityRole("guest")
- && !ejbModRef.getEJBJar().containsSecurityRole("Joe")
- && ejbModRef.getEJBJar().containsSecurityRole("guest"));
-
- earFile.saveAsNoReopen(AutomatedBVT.baseDirectory +"testOutput/SecurityRoleTests/newSample.ear");
-
-}
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/SimpleTests.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/SimpleTests.java
deleted file mode 100644
index 5ba873b4..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/SimpleTests.java
+++ /dev/null
@@ -1,433 +0,0 @@
-package org.eclipse.jst.j2ee.archive.test;
-
-/*
-* Licensed Material - Property of IBM
-* (C) Copyright IBM Corp. 2001 - All Rights Reserved.
-* US Government Users Restricted Rights - Use, duplication or disclosure
-* restricted by GSA ADP Schedule Contract with IBM Corp.
-*/
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.jst.j2ee.application.Application;
-import org.eclipse.jst.j2ee.application.Module;
-import org.eclipse.jst.j2ee.common.CommonPackage;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchiveFactory;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchivePackage;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EJBJarFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EJBModuleRef;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.File;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.ModuleFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.ModuleRef;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.ValidateXmlCommand;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.WARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.WebModuleRef;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.XmlValidationResult;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.SaveFailureException;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveInit;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveOptions;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-import org.eclipse.jst.j2ee.ejb.ContainerManagedEntity;
-import org.eclipse.jst.j2ee.ejb.EJBJar;
-import org.eclipse.jst.j2ee.ejb.EjbPackage;
-import org.eclipse.jst.j2ee.ejb.Entity;
-import org.eclipse.jst.j2ee.ejb.Session;
-import org.eclipse.jst.j2ee.webapplication.WebApp;
-import org.eclipse.jst.j2ee.webapplication.WebapplicationPackage;
-
-
-/**
- * Insert the type's description here.
- * Creation date: (12/11/00 10:26:11 AM)
- * @author: Administrator
- */
-public class SimpleTests extends TestCase {
- private final static String copyright = "(c) Copyright IBM Corporation 2001."; //$NON-NLS-1$
- /**
- * SimpleTests constructor comment.
- * @param name java.lang.String
- */
- public SimpleTests(String name) {
- super(name);
- }
- public boolean isEmpty(Collection adapters) {
- if (adapters.isEmpty())
- return true;
- for (Iterator iter = adapters.iterator(); iter.hasNext();) {
- if (iter.next() != null)
- return false;
- }
- return true;
- }
- public CommonarchiveFactory getArchiveFactory() {
- return CommonarchivePackage.eINSTANCE.getCommonarchiveFactory();
- }
- /**
- * Starts the application.
- * @param args an array of command-line arguments
- */
- public static void main(java.lang.String[] args) {
- String[] className = { "com.ibm.etools.archive.test.SimpleTests", "-noloading" };
- TestRunner.main(className);
- }
- public void printApplToConsole(Application appl) {
-
- List modules = appl.getModules();
- for (int i = 0; i < modules.size(); i++) {
- System.out.println(modules.get(i));
- }
- }
- public void printEJBJarToConsole(EJBJar ejbJar) {
-
- List ejbs = ejbJar.getEnterpriseBeans();
- for (int i = 0; i < ejbs.size(); i++) {
- System.out.println(ejbs.get(i));
- }
-
- }
- public void printWebAppToConsole(WebApp webApp) {
- List servlets = webApp.getServlets();
-
- for (int i = 0; i < servlets.size(); i++) {
- System.out.println(servlets.get(i));
- }
-
- }
- public static junit.framework.Test suite() {
- return new TestSuite(SimpleTests.class);
- }
- public void testContainerManagedEntityExtensionRead() throws Exception {
- CommonarchiveFactory factory = CommonarchivePackage.eINSTANCE.getCommonarchiveFactory();
- EJBJarFile jarFile = (EJBJarFile) factory.openArchive(AutomatedBVT.baseDirectory + "cmpsample.jar");
- EJBJar jar = jarFile.getDeploymentDescriptor();
-
- }
- public void testEJB11JarAdd() throws Exception {
- EARFile _earFile = getArchiveFactory().createEARFileInitialized(AutomatedBVT.baseDirectory + "testOutput/TestEAREJBAdd.ear");
- CommonarchiveFactory factory = CommonarchivePackage.eINSTANCE.getCommonarchiveFactory();
- EJBJarFile jar = (EJBJarFile) factory.openArchive(AutomatedBVT.baseDirectory + "ejb_compat_entitycmp.jar");
- jar.setURI(AutomatedBVT.baseDirectory + "ejb_compat_entitycmp.jar");
- _earFile.addCopy(jar);
- _earFile.save();
- }
- public void testEJBSetAbstractSchemaName() throws Exception {
- String testSm = AutomatedBVT.baseDirectory + "TestSchema";
- CommonarchiveFactory factory = CommonarchivePackage.eINSTANCE.getCommonarchiveFactory();
- EJBJarFile jarFile = (EJBJarFile) factory.openArchive(AutomatedBVT.baseDirectory + "cmpsample.jar");
- EJBJar jar = jarFile.getDeploymentDescriptor();
- List lst = jar.getContainerManagedBeans();
-
- //I know this will be a CMP, so, lets try set/get on it..
- ContainerManagedEntity cmp = (ContainerManagedEntity) lst.get(0);
-
- //System.out.println("Setting Schema name to: " + testSm);
- cmp.setAbstractSchemaName(testSm);
- //Retrieve it and see if it matches
- //System.out.println("Getting schema name: " + cmp.getAbstractSchemaName());
- assertTrue(cmp.getAbstractSchemaName().equals(testSm));
- }
- /**
- * This excercises the index adapter on Container
- */
- public void testIndexing() throws Exception {
- Archive anArchive = getArchiveFactory().openArchive(AutomatedBVT.baseDirectory + "foo.jar");
- String uri = "com/ibm/etools/archive/test/SimpleTests.java";
-
- List files = anArchive.getFiles();
-
- File aFile = anArchive.getFile(uri);
- assertTrue("Adapter should be attached to aFile", !isEmpty(aFile.eAdapters()));
-
- files.remove(aFile);
-
- assertTrue("Adapter should not be attached to aFile", isEmpty(aFile.eAdapters()));
-
- assertTrue("Contains should return false", !anArchive.containsFile(uri));
-
- File copy = anArchive.addCopy(aFile);
-
- assertTrue("Contains should return true", anArchive.containsFile(uri));
-
- String renamedURI = "com/ibm/goobledygook";
- copy.setURI(renamedURI);
-
- assertTrue("Contains should return false for old uri", !anArchive.containsFile(uri));
-
- assertTrue("Contains should return true for new uri", anArchive.containsFile(renamedURI));
-
- }
- /**
- * This excercises the index adapter on Container
- * Tests notifications with add/remove of lists, and that adapters are set post copy
- */
- public void testIndexingWithCollections() throws Exception {
- Archive anArchive = getArchiveFactory().openArchive(AutomatedBVT.baseDirectory + "bankejbs.jar");
- EARFile earFile = getArchiveFactory().createEARFileInitialized(AutomatedBVT.baseDirectory + "bar.ear");
- earFile.addCopy(anArchive);
- anArchive = (Archive) earFile.getFile(AutomatedBVT.baseDirectory + "bankejbs.jar");
-
- assertTrue("Index out of sync", !anArchive.getFiles().isEmpty() && anArchive.isIndexed());
- List files = anArchive.getFiles();
- for (int i = 0; i < files.size(); i++) {
- File aFile = (File) files.get(i);
- assertTrue("Index out of whack; containment should be true", anArchive.containsFile(aFile.getURI()));
- assertTrue("Adapter should be attached to aFile", !isEmpty(aFile.eAdapters()));
- }
-
- List filesToAdd = getArchiveFactory().openReadOnlyDirectory(AutomatedBVT.baseDirectory + "WarTestClasses").getFilesRecursive();
- List addedFiles = anArchive.addCopyFiles(filesToAdd);
-
- assertTrue("Files added incorrectly", !filesToAdd.isEmpty() && filesToAdd.size() == addedFiles.size());
-
- for (int i = 0; i < addedFiles.size(); i++) {
- File aFile = (File) addedFiles.get(i);
- assertTrue("Contains should be true", anArchive.containsFile(aFile.getURI()));
- assertTrue("Should be same instance", anArchive.getFile(aFile.getURI()) == aFile);
- assertTrue("Adapter should be attached to aFile", !isEmpty(aFile.eAdapters()));
- }
- anArchive.getFiles().removeAll(addedFiles);
-
- for (int i = 0; i < addedFiles.size(); i++) {
- File aFile = (File) addedFiles.get(i);
- assertTrue("Adapter should not be attached to aFile", isEmpty(aFile.eAdapters()));
- assertTrue("Contains should return false", !anArchive.containsFile(aFile.getURI()));
- }
- getArchiveFactory().closeOpenArchives();
- }
- /**
- * Very basic method to open an archive and save it as a directory to a new destination. Requires visual inspection
- * for verification. Nested jars will not be exploded
- */
- public void testOpenAndExtract1() throws Exception {
-
- String in = AutomatedBVT.baseDirectory + "sample.ear";
- EARFile earFile = (EARFile) getArchiveFactory().openArchive(in);
- //System.out.println("EAR spec version " + earFile.getSpecVersion() + " detected.");
-
- String out = AutomatedBVT.baseDirectory + "testOutput/SimpleTests/sample-expanded-out1.ear";
- earFile.extractTo(out, Archive.EXPAND_NONE);
- earFile.close();
- }
- /**
- * Very basic method to open an archive and save it as a directory to a new destination. Requires visual inspection
- * for verification. Nested wars will be exploded but other nested jars will not. This method emulates the websphere install.
- * the archive is opened as read only; test that no temp files are created by putting a breakpoint in ArchiveUtil#createTempFile(String, File)
- * Also the archive is opened with java reflection disabled. Verify no reflection occurs by putting a breakpoints in the constructors
- * of JavaJDKAdapterFactory, and the method reflectValues() in each of the subclasses of JdkAdaptor.
- */
- public void testOpenAndExtract2() throws Exception {
-
- String in = AutomatedBVT.baseDirectory + "sample.ear";
- ArchiveOptions options = new ArchiveOptions();
- options.setIsReadOnly(true);
- options.setUseJavaReflection(false);
- EARFile earFile = (EARFile) getArchiveFactory().openArchive(options, in);
- //The following code forces the load of all the deployment descriptors, just to make sure java reflection doesn't happen
- List moduleRefs = earFile.getModuleRefs();
- for (int i = 0; i < moduleRefs.size(); i++) {
- ModuleRef m = (ModuleRef) moduleRefs.get(i);
- m.getDeploymentDescriptor();
-
- }
-
- String out = "testOutput/SimpleTests/sample-expanded-out2.ear";
- earFile.extractTo(out, Archive.EXPAND_WAR_FILES);
- earFile.close();
- }
- /**
- * Very basic method to open an archive and save it as a directory to a new destination. Requires visual inspection
- * for verification. Nested wars and ejb jars will be exploded but other nested jars will not
- */
- public void testOpenAndExtract3() throws Exception {
-
- String in = AutomatedBVT.baseDirectory + "sample.ear";
- EARFile earFile = (EARFile) getArchiveFactory().openArchive(in);
- String out = AutomatedBVT.baseDirectory + "testOutput/SimpleTests/sample-expanded-out3.ear";
- earFile.extractTo(out, Archive.EXPAND_WAR_FILES | Archive.EXPAND_EJBJAR_FILES);
- earFile.close();
- }
- /**
- * Opens an ear file, and for each module, writes it's dd components to the console. Requires visual inspection
- * for verification
- */
- public void testOpenAndRead() throws Exception {
-
- String in = AutomatedBVT.baseDirectory + "sample.ear";
- EARFile earFile = (EARFile) getArchiveFactory().openArchive(in);
-
- Application appl = earFile.getDeploymentDescriptor();
- printApplToConsole(appl);
-
- List moduleRefs = earFile.getModuleRefs();
-
- for (int i = 0; i < moduleRefs.size(); i++) {
- ModuleRef aModuleRef = (ModuleRef) moduleRefs.get(i);
- if (aModuleRef.isWeb()) {
- WebModuleRef wRef = (WebModuleRef) aModuleRef;
- printWebAppToConsole(wRef.getWebApp());
-
- } else if (aModuleRef.isEJB()) {
- EJBModuleRef eRef = (EJBModuleRef) aModuleRef;
- printEJBJarToConsole(eRef.getEJBJar());
-
- }
- }
- }
- /**
- * Very basic method to open an archive and save it as a jar file to a new destination. Requires visual inspection
- * for verification
- */
- public void testOpenAndSaveAsJarFile() throws Exception {
-
- String in = AutomatedBVT.baseDirectory + "sample.ear";
- EARFile earFile = (EARFile) getArchiveFactory().openArchive(in);
- String out = AutomatedBVT.baseDirectory + "testOutput/SimpleTests/sample-copy.ear";
- earFile.saveAsNoReopen(out);
- }
- /**
- * Test case created as a result of a defect report that currently cannot be reproduced; open an expanded ear file and save it out
- * as a jar file
- */
- public void testOpenDirectoryAndSaveAsJarFile() throws Exception {
-
- String in = AutomatedBVT.baseDirectory + "sample_expanded.ear";
- in = new java.io.File(in).getAbsolutePath();
- //System.out.println(in);
- EARFile earFile = (EARFile) getArchiveFactory().openArchive(in);
- //Added this line to see if loading the dd would make a difference
- earFile.getDeploymentDescriptor();
- String out = "testOutput/SimpleTests/sample-jarred.ear";
- out = new java.io.File(out).getAbsolutePath();
- //System.out.println(out);
- earFile.saveAsNoReopen(out);
- }
- /**
- * @see Archive#canClose()
- */
- public void testSafeClose() throws Exception {
-
- String in = AutomatedBVT.baseDirectory + "sample.ear";
- EARFile earFile = getArchiveFactory().openEARFile(in);
- List modules = earFile.getDeploymentDescriptor().getModules();
- EJBJarFile ejbJarFile = null;
-
- for (int i = 0; i < modules.size(); i++) {
- Module aModule = (Module) modules.get(i);
- if (aModule.isEjbModule()) {
- ejbJarFile = (EJBJarFile) earFile.getFile(aModule.getUri());
- //System.out.println("EJBJar spec version " + ejbJarFile.getSpecVersion() + " detected.");
-
- break;
- }
- }
-
- assertTrue("EJBJarFile should not be null", ejbJarFile != null);
-
- EARFile newEarFile = getArchiveFactory().createEARFileInitialized("testOutput/SimpleTests/safeClose1.ear");
- newEarFile.addCopy(ejbJarFile);
- assertTrue(!earFile.getDependentOpenArchives().isEmpty() && !ejbJarFile.getDependentOpenArchives().isEmpty());
-
- newEarFile.save();
- assertTrue(earFile.getDependentOpenArchives().isEmpty() && ejbJarFile.getDependentOpenArchives().isEmpty());
- earFile.close();
- newEarFile.close();
- }
- /**
- * CMVC defect 99544 - If a save fails and the file didn't exist, one should not
- * be created
- */
- public void testSaveFailure() throws Exception {
-
- String in = AutomatedBVT.baseDirectory + "sample.ear";
- String out = AutomatedBVT.baseDirectory + "testOutput/SimpleTests/saveFailure.ear";
- EARFile earFile = getArchiveFactory().openEARFile(in);
- List modules = earFile.getDeploymentDescriptor().getModules();
- EJBJarFile ejbJarFile = null;
-
- for (int i = 0; i < modules.size(); i++) {
- Module aModule = (Module) modules.get(i);
- if (aModule.isEjbModule()) {
- ejbJarFile = (EJBJarFile) earFile.getFile(aModule.getUri());
- break;
- }
- }
-
- assertTrue("EJBJarFile should not be null", ejbJarFile != null);
-
- EARFile newEarFile = getArchiveFactory().createEARFileInitialized(out);
- newEarFile.addCopy(ejbJarFile);
- ejbJarFile.close();
- try {
- newEarFile.save();
- } catch (SaveFailureException expected) {
- System.out.println("Expected save failure occurred");
- return;
- } finally {
- assertTrue("File should not exist", !(new java.io.File(out).exists()));
- getArchiveFactory().closeOpenArchives();
- }
- assertTrue("Save should have failed", false);
- }
- /**
- * Opens an ear file, makes a few changes to ensure the xml is not valid, and validates the xml in all the dds; verifies that
- * sax exceptions are collected
- */
- public void testXmlValidation() throws Exception {
-
- String in = AutomatedBVT.baseDirectory + "sample.ear";
- EARFile earFile = getArchiveFactory().openEARFile(in);
-
- Application appl = earFile.getDeploymentDescriptor();
- appl.getSecurityRoles().add(CommonPackage.eINSTANCE.getCommonFactory().createSecurityRole());
-
- List moduleFiles = earFile.getModuleFiles();
-
- for (int i = 0; i < moduleFiles.size(); i++) {
- ModuleFile aModuleFile = (ModuleFile) moduleFiles.get(i);
- if (aModuleFile.isWARFile()) {
- WARFile aWarFile = (WARFile) aModuleFile;
- aWarFile.getDeploymentDescriptor().getServlets().add(WebapplicationPackage.eINSTANCE.getWebapplicationFactory().createServlet());
- } else if (aModuleFile.isEJBJarFile()) {
- EJBJarFile anEjbJarFile = (EJBJarFile) aModuleFile;
- anEjbJarFile.getDeploymentDescriptor().getEnterpriseBeans().add(EjbPackage.eINSTANCE.getEjbFactory().createEntity());
- anEjbJarFile.getDeploymentDescriptor().getAssemblyDescriptor().getSecurityRoles().add(CommonPackage.eINSTANCE.getCommonFactory().createSecurityRole());
- }
- }
- Command cmd = new ValidateXmlCommand(earFile);
- cmd.execute();
- List errors = (List) cmd.getResult();
- assertTrue("Total validation errors should be 3, instead of "+errors.size(), errors.size() == 3);
- for (int i = 0; i < 3; i++) {
- XmlValidationResult result = (XmlValidationResult) errors.get(i);
- if (i == 1)
- assertTrue("The ejb module should have 2 errors instead of "+ result.getCaughtExceptions().size(), result.getCaughtExceptions().size() == 2);
- else
- assertTrue("The web module should have 1 error instead of "+ result.getCaughtExceptions().size(), result.getCaughtExceptions().size() == 1);
- }
- earFile.close();
- }
- protected void setUp() throws Exception {
- super.setUp();
- ArchiveInit.init();
- }
-
- public void testReadEmptyTags() throws Exception {
- String uri = AutomatedBVT.baseDirectory + "CHKJ280X.jar";
- EJBJarFile jarfile = getArchiveFactory().openEJBJarFile(uri);
- EJBJar jar = jarfile.getDeploymentDescriptor();
- Session sess = (Session) jar.getEnterpriseBeans().get(0);
- Entity entity = (Entity) jar.getEnterpriseBeans().get(1);
- assertFalse("Value should be unset", entity.isSetReentrant());
- assertFalse("Value should be unset", sess.isSetSessionType());
- assertFalse("Value should be unset", sess.isSetTransactionType());
-}
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/TestInvalidXmlMultiplicity.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/TestInvalidXmlMultiplicity.java
deleted file mode 100644
index 5c8dced2..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/TestInvalidXmlMultiplicity.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Created on Dec 2, 2003
- *
- */
-package org.eclipse.jst.j2ee.archive.test;
-
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-
-import org.eclipse.jst.j2ee.commonarchivecore.internal.WARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.DeploymentDescriptorLoadException;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-import org.eclipse.jst.j2ee.internal.IWrappedException;
-
-
-/**
- * @author schacher
- */
-public class TestInvalidXmlMultiplicity extends AbstractArchiveTest {
-
- /**
- * @param name
- */
- public TestInvalidXmlMultiplicity(String name) {
- super(name);
- }
-
- /**
- * Starts the application.
- * @param args an array of command-line arguments
- */
- public static void main(java.lang.String[] args) {
- String[] className = { "com.ibm.etools.archive.test.TestInvalidXmlMultiplicity", "-noloading" };
- TestRunner.main(className);
- }
-
- public static junit.framework.Test suite() {
- return new TestSuite(TestInvalidXmlMultiplicity.class);
- }
-
- public void test1() throws Exception {
- String uri = AutomatedBVT.baseDirectory + "BadJspConfig.war";
- runTest(uri);
- }
-
- public void test2() throws Exception {
- String uri = AutomatedBVT.baseDirectory + "BadLoginConfig.war";
- runTest(uri);
- }
-
- public void test3() throws Exception {
- String uri = AutomatedBVT.baseDirectory + "BadSessionConfig.war";
- runTest(uri);
- }
-
- public void runTest(String uri) throws Exception {
- IWrappedException ex = null;
- WARFile war = getArchiveFactory().openWARFile(uri);
- try {
- war.getDeploymentDescriptor();
- } catch (DeploymentDescriptorLoadException ddex) {
- ex = ddex;
- }
- assertNotNull("Exception should have been caught", ex);
- Exception inner = ex.getNestedException();
-
- while (ex != null) {
- if (inner instanceof IWrappedException) {
- ex = (IWrappedException)inner;
- if (ex.getNestedException() != null)
- inner = ex.getNestedException();
- } else
- ex = null;
- }
-
- assertTrue("The exception should be an IllegalStateException", inner instanceof IllegalStateException);
- war.close();
- }
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/TestModuleClassLoading.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/TestModuleClassLoading.java
deleted file mode 100644
index 415e874a..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/TestModuleClassLoading.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.archive.test;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.internal.impl.JavaClassImpl;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchiveFactory;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchivePackage;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.impl.CommonarchiveFactoryImpl;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-
-
-public class TestModuleClassLoading extends TestCase {
- static String testClass = "client.Subtract";
-
-
-
- /**
- *
- */
- public TestModuleClassLoading() {
- super();
- }
-
- public TestModuleClassLoading(String name) {
- super(name);
- }
-
- public CommonarchiveFactory getArchiveFactory() {
- return CommonarchivePackage.eINSTANCE.getCommonarchiveFactory();
- }
- /**
- * Starts the application.
- * @param args an array of command-line arguments
- */
- public static void main(java.lang.String[] args) {
- String[] className = {"com.ibm.etools.archive.test.TestModuleClassLoading", "-noloading"};
- TestRunner.main(className);
- }
- public static junit.framework.Test suite() {
- return new TestSuite(TestModuleClassLoading.class);
- }
- public static void testAddModuleClassLoading() throws Exception {
- String[] files = { "PROTO.ear","SEIinAnotherJar.ear", "SEIinWEB-INF_lib_jar.ear" };
-
- if (files.length == 0) {
- System.out.println("Usage: args specify full path to ear files.");
- }
-
- // com.ibm.websphere.models.config.init.ConfigInit.init();
- for (int i = 0; i < files.length; i++) {
- String filename = files[i];
- CommonarchiveFactory factory = CommonarchiveFactoryImpl.getActiveFactory();
-
- String in = AutomatedBVT.baseDirectory + files[i];
- try {
- EARFile earFile = factory.openEARFile (in);
- System.out.println ("uri: " + earFile.getURI());
- System.out.println("Testing " + earFile.getURI());
- doModules(earFile);
- } catch (Exception e) {
- System.out.println(e);
- }
- }
- }
-
-
-
- public static void doModules(EARFile earFile) {
- List modules = earFile.getModuleFiles();
- for (int i = 0; i < modules.size(); i++) {
- Archive module = (Archive) modules.get(i);
- System.out.print("\tLooking for class " + testClass + " in module " + module.getURI());
- doLoad(module, testClass);
- }
- } // validateModules
-
- private static void doLoad(Archive module, String testClass) {
- try {
- JavaClass javaClass =
- (JavaClass) JavaClassImpl.reflect(testClass, module.getResourceSet());
- if (!(javaClass).isExistingType()) {
- // This is what happens if the class can't be loaded.
- System.out.println("- NOT FOUND - isExistingType returns false.");
- } else {
- System.out.println(" - found: isExistingType returns true.");
- }
- } catch (RuntimeException e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/WARFileTests.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/WARFileTests.java
deleted file mode 100644
index b7c126eb..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/test/WARFileTests.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package org.eclipse.jst.j2ee.archive.test;
-
- /*
- * Licensed Material - Property of IBM
- * (C) Copyright IBM Corp. 2001 - All Rights Reserved.
- * US Government Users Restricted Rights - Use, duplication or disclosure
- * restricted by GSA ADP Schedule Contract with IBM Corp.
- */
-
-import java.util.List;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.swingui.TestRunner;
-
-import org.eclipse.jst.j2ee.commonarchivecore.internal.Archive;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchiveFactory;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.CommonarchivePackage;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.File;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.ReadOnlyDirectory;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.WARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.helpers.ArchiveConstants;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil;
-import org.eclipse.jst.j2ee.core.tests.bvt.AutomatedBVT;
-
-/**
- * Insert the type's description here.
- * Creation date: (12/15/00 2:26:04 PM)
- * @author: Administrator
- */
-public class WARFileTests extends TestCase {
- private final static String copyright = "(c) Copyright IBM Corporation 2001.";//$NON-NLS-1$
-/**
- * WARFileTests constructor comment.
- * @param name java.lang.String
- */
-public WARFileTests(String name) {
- super(name);
-}
-public CommonarchiveFactory getArchiveFactory() {
- return CommonarchivePackage.eINSTANCE.getCommonarchiveFactory();
-}
-/**
- * Starts the application.
- * @param args an array of command-line arguments
- */
-public static void main(java.lang.String[] args) {
- String[] className = {"com.ibm.etools.archive.test.WARFileTests", "-noloading"};
- TestRunner.main(className);
-}
-public static junit.framework.Test suite() {
- return new TestSuite(WARFileTests.class);
-}
-public void testAddCopyClass() throws Exception {
-
- WARFile aWarFile = (WARFile)getArchiveFactory().openArchive(AutomatedBVT.baseDirectory +"example2.war");
-
- ReadOnlyDirectory sampleDirectory = getArchiveFactory().openReadOnlyDirectory(AutomatedBVT.baseDirectory +"WarTestClasses");
-
- int initialSize = aWarFile.getClasses().size();
-
- File aFile = sampleDirectory.getFileInSelfOrSubdirectory("com/ibm/etools/archive/test/WARFileTests.class");
-
- aWarFile.addCopyClass(aFile);
- assertTrue(aWarFile.getClasses().size() == initialSize+1);
-
- String classURI = ArchiveUtil.concatUri(ArchiveConstants.WEBAPP_CLASSES_URI, aFile.getURI(), '/');
- assertTrue(aWarFile.containsFile(classURI));
- //System.out.println(aWarFile.getURI()+" contains class "+classURI);
-
- aWarFile.saveAsNoReopen(AutomatedBVT.baseDirectory +"testOutput/WarTests/addCopyClass.war");
-
-}
-
-public void testAddCopyLib() throws Exception {
-
- WARFile aWarFile = (WARFile)getArchiveFactory().openArchive(AutomatedBVT.baseDirectory + "example2.war");
-
- Archive lib = getArchiveFactory().openArchive(AutomatedBVT.baseDirectory + "foo.jar");
-
- int initialSize = aWarFile.getLibs().size();
-
- aWarFile.addCopyLib(lib);
- assertTrue(aWarFile.getLibs().size() == initialSize+1);
-
- String libURI = ArchiveUtil.concatUri(ArchiveConstants.WEBAPP_LIB_URI, lib.getURI(), '/');
- assertTrue(aWarFile.containsFile(libURI));
- //System.out.println(aWarFile.getURI()+" contains lib "+libURI);
-
- aWarFile.saveAsNoReopen("testOutput/WarTests/addCopyLib.war");
-
-}
-
-public void testListClassesAndLibs() throws Exception {
-
- WARFile aWarFile = (WARFile)getArchiveFactory().openArchive(AutomatedBVT.baseDirectory + "example2.war");
-
- List libs = aWarFile.getLibs();
- List classes = aWarFile.getClasses();
- List resources = aWarFile.getResources();
-// System.out.println("WAR spec version "+aWarFile.getSpecVersion()+" detected.");
-// System.out.println("example2.war contains "+classes.size()+ " files in classes");
-// System.out.println("example2.war contains "+libs.size()+ " libs");
-// System.out.println("example2.war contains "+resources.size()+ " resources");
-
-}
-
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/testutilities/EAttributeDescriptor.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/testutilities/EAttributeDescriptor.java
deleted file mode 100644
index d8500780..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/testutilities/EAttributeDescriptor.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Created on May 1, 2003
- *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.jst.j2ee.archive.testutilities;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-/**
- * @author administrator
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class EAttributeDescriptor {
-
- EStructuralFeature feature;
- EClass metaClass;
-
- /**
- *
- */
- public EAttributeDescriptor(EStructuralFeature feature, EClass metaClass) {
- this.feature = feature;
- this.metaClass = metaClass;
- }
-
- /**
- * @return
- */
- public EClass getMetaClass() {
- return metaClass;
- }
-
- /**
- * @param class1
- */
- public void setMetaClass(EClass class1) {
- metaClass = class1;
- }
-
- public boolean equals(Object object) {
- EAttributeDescriptor o = (EAttributeDescriptor)object;
- return o.getFeature() == getFeature() && o.getMetaClass() == getMetaClass();
- }
-
- public int hashCode() {
- return feature.hashCode() ^ metaClass.hashCode();
- }
-
-
- /**
- * @return
- */
- public EStructuralFeature getFeature() {
- return feature;
- }
-
- /**
- * @param attribute
- */
- public void setFeature(EAttribute attribute) {
- this.feature = attribute;
- }
-
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/testutilities/EMFAttributeFeatureGenerator.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/testutilities/EMFAttributeFeatureGenerator.java
deleted file mode 100644
index 20ad5fa5..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/testutilities/EMFAttributeFeatureGenerator.java
+++ /dev/null
@@ -1,462 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.archive.testutilities;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EEnum;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.jem.java.internal.impl.JavaClassImpl;
-import org.eclipse.jst.j2ee.common.CommonPackage;
-import org.eclipse.jst.j2ee.ejb.EjbPackage;
-import org.eclipse.jst.j2ee.webapplication.WebapplicationPackage;
-
-public class EMFAttributeFeatureGenerator {
- public static String avClass[];
- protected static int count = 0;
- protected static Random randomGenerator = new Random();
- protected static int maxNumberOfProjectsCreated = 1000;
- protected static Map enumMap = new HashMap();
- protected static int paramCount;
- protected static String[] langArray = new String[] { "EN","FR","DE","JP","CN","BR","SP"};
- protected static int langCount = 0;
- protected static Map booleanMap = new HashMap();
- protected static Map attIndex = new HashMap();
- protected static boolean specialNumberGen = false;
- protected static String httpArray[] = null;
- protected static int httpArrayIndex = 0;
-
- public static int version;
- public static int moduleType;
- //static versions
- public static final int VERSION_1_2 = 0;
- public static final int VERSION_1_3 = 1;
- public static final int VERSION_1_4 = 2;
-
- public static final int APPICATION = 0;
- public static final int APP_CLIENT = 1;
- public static final int CONNECTOR = 2;
- public static final int EJB = 3;
- public static final int WEB = 4;
-
- public EMFAttributeFeatureGenerator() {
- super();
- }
-
- public static void resetCount() {
- count = 0;
- return;
- }
- public static Object createAttribute(EAttribute att, EObject obj){
- return createAttribute(new EAttributeDescriptor(att,obj.eClass()));
- }
-
- public static Object createAttribute(EAttribute att, EClass eClass){
- return createAttribute(new EAttributeDescriptor(att,eClass));
- }
-
- public static Object createAttribute(EAttribute att, EObject obj, boolean special){
- specialNumberGen = special;
- return createAttribute(new EAttributeDescriptor(att,obj.eClass()));
- }
-
- public static Object createAttribute(EAttribute att, EObject obj, boolean special, int ver, int modType) {
- specialNumberGen = special;
- version = ver;
- moduleType = modType;
- return createAttribute(new EAttributeDescriptor(att,obj.eClass()));
- }
-
- protected static Object createAttribute(EAttributeDescriptor att) {
- EClassifier meta = att.getFeature().getEType();
- if (meta instanceof EEnum && att.getFeature().isMany()){
- List collection = new ArrayList();
- collection.add(createEnum(att));
- return collection;
- }
- else if (meta instanceof EEnum)
- return createEnum(att);
- else if ((version == VERSION_1_3 || version == VERSION_1_2) && att.getFeature().equals(WebapplicationPackage.eINSTANCE.getHTTPMethodType_HttpMethod()))
- return createSpecialHttpMethodsFor13();
- else if (version == VERSION_1_3 && att.getFeature().equals(CommonPackage.eINSTANCE.getEJBLocalRef_Local()))
- return generateRandomAttributeString(new EAttributeDescriptor(CommonPackage.eINSTANCE.getEjbRef_Remote(), att.getMetaClass()));
- else if (version == VERSION_1_3 && att.getFeature().equals(CommonPackage.eINSTANCE.getEJBLocalRef_LocalHome()))
- return generateRandomAttributeString(new EAttributeDescriptor(CommonPackage.eINSTANCE.getEjbRef_Home(),att.getMetaClass()));
- else if (att.getFeature().getName().equals("parms"))
- return createParams(att);
- else if (att.getFeature().getName().startsWith("location") && version == VERSION_1_4)
- return createLocation(att);
- else if (att.getFeature().getName().startsWith("locale") && version == VERSION_1_4)
- return createLocale();
- else if (att.getFeature().getName().equals("lang"))
- return createLang(att);
- else if (att.getFeature().getName().equals("version"))
- if (att.getFeature() == EjbPackage.eINSTANCE.getContainerManagedEntity_Version())
- return "2.x";
- else
- return createVersion(att);
- else if (att.getFeature().getName().equals("mimeType") && version == VERSION_1_4)
- return "text/plain";
- else if (att.getFeature().getName().equals("errorCode") && version == VERSION_1_4)
- return "404";
- else if (att.getFeature().getName().equals("formLoginPage") && version == VERSION_1_4)
- return "/testFormLoginPage";
- else if (att.getFeature().getName().equals("formErrorPage") && version == VERSION_1_4)
- return "/testFormErrorpage";
- else if(att.getFeature().getName().equals("link") && version == VERSION_1_4)
- return "roleName_0";
- else if(att.getFeature().getName().equals("specVersion") && version == VERSION_1_4)
- return "1.5";
- else if (att.getFeature().isMany())
- return createCollection(att);
- else if (meta.getInstanceClassName().equals("java.lang.String"))
- return generateRandomAttributeString(att);
- else if (meta.getInstanceClassName().equals("boolean"))
- return generateRandomBoolean(att);
- else if (meta.getInstanceClassName().equals("java.util.List"))
- return createCollection(att);
- else if(meta.getName().equals("QName")){
- return generateRandomQName(att);
- }
- switch (meta.getClassifierID()) {
- case EcorePackage.ESTRING:
- return generateRandomAttributeString(att);
- case EcorePackage.EBOOLEAN_OBJECT:
- case EcorePackage.EBOOLEAN:
- return generateRandomBoolean(att);
- case EcorePackage.EINTEGER_OBJECT:
- case EcorePackage.EINT:
- return generateRandomInteger(att);
- case EcorePackage.EFLOAT_OBJECT:
- case EcorePackage.EFLOAT:
- return generateRandomFloat(att);
- case EcorePackage.ECHARACTER_OBJECT:
- case EcorePackage.ECHAR:
- return generateRandomChar(att);
- case EcorePackage.ELONG_OBJECT:
- case EcorePackage.ELONG:
- return generateRandomLong();
- case EcorePackage.EBYTE_OBJECT:
- case EcorePackage.EBYTE:
- return generateRandomByte();
- case EcorePackage.EDOUBLE_OBJECT:
- case EcorePackage.EDOUBLE:
- return generateRandomDouble();
- case EcorePackage.ESHORT_OBJECT:
- case EcorePackage.ESHORT:
- return generateRandomShort(att);
- case EcorePackage.EJAVA_OBJECT:
- return generateRandomObject(att);
- }
- return null;
- }
-
- /**
- * @return
- */
- private static Object createLocale() {
- return "en_US";
- }
-
- /**
- * @param att
- * @return
- */
- private static Object createLocation(EAttributeDescriptor att) {
- String temp = generateRandomAttributeString(att);
- return "/." + temp;
- }
-
- public static EObject createJavaClassProxy(EStructuralFeature ref, EObject eObject) {
- if (avClass == null) {
- avClass = new String[] { "java.util.HashTable", "java.util.List", "java.sql.Data", "java.lang.Integer", "java.lang.String" };
- }
- EAttributeDescriptor feature = new EAttributeDescriptor(ref,eObject.eClass());
- if (!attIndex.containsKey(feature))
- attIndex.put(feature, new Integer(0));
- int classIndex = ((Integer)attIndex.get(feature)).intValue();
- String name = avClass[classIndex];
- classIndex++;
- if (classIndex == 5)
- classIndex = 0;
- attIndex.put(feature,new Integer(classIndex));
- return JavaClassImpl.createClassRef(name);
- }
- /**
- * @return
- */
- protected static Object createSpecialHttpMethodsFor13() {
- if (httpArray == null)
- httpArray = new String[] {
- "GET",
- "POST",
- "PUT",
- "DELETE",
- "HEAD",
- "OPTIONS",
- "TRACE"
- };
- if (httpArrayIndex >= httpArray.length)
- httpArrayIndex = 0;
- Object holder = httpArray[httpArrayIndex];
- httpArrayIndex++;
- return holder;
- }
-
- /**
- * @param att
- * @return
- */
- protected static String createVersion(EAttributeDescriptor att) {
- String versionHolder = "";
- switch (moduleType) {
- case APPICATION :
- if(version == VERSION_1_2) {
- versionHolder = "1.2";
- break;
- }
- else if(version == VERSION_1_3){
- versionHolder = "1.3";
- break;
- }
- else if(version == VERSION_1_4){
- versionHolder = "1.4";
- break;
- }
- else {
- versionHolder = "5.0";
- break;
- }
- case APP_CLIENT :
- if(version == VERSION_1_2) {
- versionHolder = "1.2";
- break;
- }
- else if(version == VERSION_1_3) {
- versionHolder = "1.3";
- break;
- }
- else if(version == VERSION_1_4) {
- versionHolder = "1.4";
- break;
- }
- else {
- versionHolder = "5.0";
- break;
- }
- case EJB :
- if(version == VERSION_1_2) {
- versionHolder = "1.1";
- break;
- }
- else if(version == VERSION_1_3) {
- versionHolder = "2.0";
- break;
- }
- else if(version == VERSION_1_4) {
- versionHolder = "2.1";
- break;
- }
- else {
- versionHolder = "3.0";
- break;
- }
- case CONNECTOR :
- if(version == VERSION_1_2) {
- versionHolder = "1.0";
- break;
- }
- else if(version == VERSION_1_3) {
- versionHolder = "1.0";
- break;
- }
- else {
- versionHolder = "1.5";
- break;
- }
- case WEB :
- if(version == VERSION_1_2) {
- versionHolder = "2.2";
- break;
- }
- else if(version == VERSION_1_3) {
- versionHolder = "2.3";
- break;
- }
- else if(version == VERSION_1_4) {
- versionHolder = "2.4";
- break;
- }
- else {
- versionHolder = "2.5";
- break;
- }
- }
-
- return versionHolder;
- }
-
- protected static Object createParams(EAttributeDescriptor att) {
- if (paramCount == 0){
- paramCount++;
- return null;
- }
- else if (paramCount == 1){
- paramCount++;
- return "";
- }
- String r = "";
- for (int i = 1 ; i < paramCount ;i++){
- r += generateRandomAttributeString(att) + " ";
- }
- paramCount++;
- if (paramCount == 5)
- paramCount = 0;
- return r;
-
- }
-
-
- protected static Object createLang(EAttributeDescriptor att) {
- String name = langArray[langCount];
- langCount++;
- if (langCount == 7)
- langCount = 0;
- return name;
- }
-
- protected static Object createCollection(EAttributeDescriptor att) {
- ArrayList list = new ArrayList();
- list.add(generateRandomAttributeString(att));
- return list;
- }
-
-
- protected static Object generateRandomObject(EAttributeDescriptor att) {
- return generateRandomAttributeString(att);
- }
-
- protected static Object createEnum(EAttributeDescriptor att) {
- EEnum anEnum = (EEnum) att.getFeature().getEType();
- if (!enumMap.containsKey(att)){
- if (att.getFeature().getName().equals("authMethod"))
- enumMap.put(att,new Integer(1));
- else
- enumMap.put(att,new Integer(0));
- }
- int pos = ((Integer)enumMap.get(att)).intValue();
- EList literals = anEnum.getELiterals();
- int size = literals.size();
- if (pos == size)
- pos = 0;
- Object holder = anEnum.getEEnumLiteral(pos).getInstance();
- pos++;
- enumMap.put(att,new Integer(pos));
- return holder;
-
- }
- public static Object generateRandomClassname(EAttributeDescriptor att) {
- return "com.foo." + generateRandomAttributeString(att);
- }
-
- //REVISIT
- protected static Object generateRandomShort(EAttributeDescriptor att) {
- return new Short(Short.parseShort(String.valueOf(generateNumber(att))));
- }
-
- protected static Object generateRandomDouble() {
- return new Double(randomGenerator.nextDouble());
- }
- //REVISIT
- protected static Object generateRandomByte() {
- return new Byte("byte");
- }
-
- protected static Object generateRandomLong() {
- return new Long(randomGenerator.nextLong());
- }
-
- protected static Object generateRandomChar(EAttributeDescriptor att) {
- return new Character(generateRandomAttributeString(att).charAt(0));
- }
-
-
- protected static Object generateRandomFloat(EAttributeDescriptor att) {
- return new Float(randomGenerator.nextFloat());
- }
-
- protected static Object generateRandomInteger(EAttributeDescriptor att) {
- return new Integer(generateNumber(att));
- }
-
- protected static char [] intToCharMapping = new char [] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };
- protected static char [] charToIntMapping = new char [] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
- protected static Object generateRandomQName(EAttributeDescriptor att) {
- char [] charArray = Integer.toString(generateNumber(att)).toCharArray();
- for(int i=0;i<charArray.length;i++){
- for(int j=0;j<charToIntMapping.length; j++){
- if (charArray[i] == charToIntMapping[j]){
- charArray[i] = intToCharMapping[j];
- break;
- }
- }
- }
- return new String(charArray);
- }
-
- protected static Object generateRandomBoolean(EAttributeDescriptor att) {
- if (!booleanMap.containsKey(att)){
- booleanMap.put(att,new Boolean(true));
- }
- Boolean holder = (Boolean)booleanMap.get(att);
- booleanMap.put(att, new Boolean(!holder.booleanValue()));
- return holder;
- }
-
- public static String generateRandomAttributeString(EAttributeDescriptor att) {
- return att.getFeature().getName() + "_" + generateNumber(att);
- }
- protected static int generateNumber(EAttributeDescriptor att) {
- if(!specialNumberGen)
- return count ++;
- else{
- if(!attIndex.containsKey(att))
- attIndex.put(att, new Integer(0));
- int holder = ((Integer) attIndex.get(att)).intValue();
- attIndex.put(att, new Integer(holder+1));
- return holder;
- }
- }
-
- public static void reset(){
- count = 0;
- enumMap = new HashMap();
- httpArrayIndex = 0;
- paramCount = 0;
- langCount = 0;
- booleanMap = new HashMap();
- attIndex = new HashMap();
- specialNumberGen = false;
- TestUtilities.reset();
- J2EEVersionCheck.cur_Tags = null;
-
- }
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/testutilities/J2EEVersionCheck.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/testutilities/J2EEVersionCheck.java
deleted file mode 100644
index 21a089da..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/testutilities/J2EEVersionCheck.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Apr 14, 2003
- *
- * To change this generated comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.jst.j2ee.archive.testutilities;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.jst.j2ee.application.ApplicationPackage;
-import org.eclipse.jst.j2ee.client.ClientPackage;
-import org.eclipse.jst.j2ee.common.CommonPackage;
-import org.eclipse.jst.j2ee.ejb.EjbPackage;
-import org.eclipse.jst.j2ee.jca.JcaPackage;
-import org.eclipse.jst.j2ee.webapplication.WebapplicationPackage;
-
-public class J2EEVersionCheck {
- public int version;
- //static versions
- public static final int VERSION_1_2 = 0;
- public static final int VERSION_1_3 = 1;
- public static final int VERSION_1_4 = 2;
- public static final int VERSION_5_0 = 3;
-
- //modules
- public static final int APPICATION = 0;
- public static final int APP_CLIENT = 1;
- public static final int CONNECTOR = 2;
- public static final int EJB = 3;
- public static final int WEB = 4;
-
- public static List cur_Tags;
- private static CommonPackage COM = CommonPackage.eINSTANCE;
-
- public J2EEVersionCheck() {
- super();
- }
- public static boolean checkAttributeVersion(EAttribute att, int version, int type){
- //TODO: Add version 1.2 excludes
- if(version == VERSION_1_3 || version == VERSION_1_2){
- if(cur_Tags == null){
- cur_Tags = new ArrayList();
- populate_1_3List(type);
- }
- }
- else if(version == VERSION_1_4 || version == VERSION_5_0){
- return true;
- }
-
- if(cur_Tags.contains(att) || cur_Tags.contains(att.getEType()))
- return false;
- return true;
- }
-
- public static boolean checkReferenceVersion(EStructuralFeature ref, int version, int type){
- //TODO: Add version 1.2 excludes
- if(version == VERSION_1_3 || version == VERSION_1_2){
- if(cur_Tags == null){
- cur_Tags = new ArrayList();
- populate_1_3List(type);
- }
- }
- else if(version == VERSION_1_4 || version == VERSION_5_0){
- return true;
- }
-
- if(cur_Tags.contains(ref) || cur_Tags.contains(ref.getEType()))
- return false;
- return true;
- }
-
- private static void populate_1_2List(int type) {
- switch (type) {
- case APPICATION :
- populate_1_2Application();
- break;
- case APP_CLIENT :
- populate_1_2AppClient();
- break;
- case EJB :
- populate_1_2EJB();
- break;
- case CONNECTOR :
- populate_1_2EJB();
- break;
- case WEB :
- populate_1_2Web();
- default :
- break;
- }
- }
-
- private static void populate_1_3List(int type) {
- switch (type) {
- case APPICATION :
- populate_1_3Application();
- break;
- case APP_CLIENT :
- populate_1_3AppClient();
- break;
- case EJB :
- populate_1_3EJB();
- break;
- case CONNECTOR :
- populate_1_3EJB();
- break;
- case WEB :
- populate_1_3Web();
- default :
- break;
- }
- }
-
- private static void populate_1_2Application(){
- populate_1_3Application();
- }
-
- private static void populate_1_2AppClient(){
- populate_1_3AppClient();
- }
-
- private static void populate_1_2EJB(){
- populate_1_3EJB();
- }
-
- private static void populate_1_2Connector(){
- populate_1_3Connector();
- }
-
- private static void populate_1_2Web(){
- populate_1_3Web();
- }
-
- //1.3
- private static void populate_1_3Application(){
- CommonPackage COM = CommonPackage.eINSTANCE;
- cur_Tags.add(COM.getIconType());
- cur_Tags.add(COM.getDisplayName());
- cur_Tags.add(COM.getDescription());
- cur_Tags.add(COM.getDescriptionGroup());
- cur_Tags.add(COM.getSecurityIdentity_Descriptions());
- cur_Tags.add(ApplicationPackage.eINSTANCE.getApplication_Version());
- }
-
- private static void populate_1_3AppClient(){
- cur_Tags.add(COM.getIconType());
- cur_Tags.add(COM.getDisplayName());
- cur_Tags.add(COM.getDescription());
- cur_Tags.add(COM.getDescriptionGroup());
- cur_Tags.add(ClientPackage.eINSTANCE.getApplicationClient_Version());
- cur_Tags.add(ClientPackage.eINSTANCE.getApplicationClient_ServiceRefs());
- cur_Tags.add(ClientPackage.eINSTANCE.getApplicationClient_MessageDestinationRefs());
- cur_Tags.add(ClientPackage.eINSTANCE.getApplicationClient_MessageDestinations());
- cur_Tags.add(COM.getMessageDestination());
- cur_Tags.add(COM.getMessageDestinationRef());
- //cur_Tags.add(ClientPackage.eINSTANCE.getApplicationClient_ServiceRefs());
- }
-
- private static void populate_1_3Connector(){
- cur_Tags.add(COM.getIconType());
- cur_Tags.add(COM.getDisplayName());
- cur_Tags.add(COM.getDescription());
- cur_Tags.add(COM.getDescriptionGroup());
- cur_Tags.add(JcaPackage.eINSTANCE.getOutboundResourceAdapter());
- cur_Tags.add(JcaPackage.eINSTANCE.getInboundResourceAdapter());
- cur_Tags.add(JcaPackage.eINSTANCE.getAdminObject());
- cur_Tags.add(JcaPackage.eINSTANCE.getConnector_Version());
- }
-
- private static void populate_1_3EJB() {
- cur_Tags.add(COM.getIconType());
- cur_Tags.add(COM.getDisplayName());
- cur_Tags.add(COM.getDescription());
- cur_Tags.add(COM.getDescriptionGroup());
- cur_Tags.add(EjbPackage.eINSTANCE.getEJBJar_Version());
- cur_Tags.add(EjbPackage.eINSTANCE.getSession_ServiceEndpoint());
- cur_Tags.add(COM.getJNDIEnvRefsGroup_MessageDestinationRefs());
- cur_Tags.add(COM.getJNDIEnvRefsGroup_ServiceRefs());
- cur_Tags.add(EjbPackage.eINSTANCE.getMessageDriven_MessagingType());
- cur_Tags.add(EjbPackage.eINSTANCE.getMessageDriven_MessageDestination());
- cur_Tags.add(EjbPackage.eINSTANCE.getMessageDriven_Link());
- cur_Tags.add(EjbPackage.eINSTANCE.getMessageDriven_ActivationConfig());
- }
-
- private static void populate_1_3Web(){
- cur_Tags.add(COM.getIconType());
- cur_Tags.add(COM.getDisplayName());
- cur_Tags.add(COM.getDescription());
- cur_Tags.add(COM.getDescriptionGroup());
- cur_Tags.add(WebapplicationPackage.eINSTANCE.getWebApp_Version());
- cur_Tags.add(WebapplicationPackage.eINSTANCE.getWebApp_JspConfig());
- cur_Tags.add(WebapplicationPackage.eINSTANCE.getWebApp_MessageDestinations());
- cur_Tags.add(WebapplicationPackage.eINSTANCE.getWebApp_LocalEncodingMappingList());
- }
-
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/testutilities/TestUtilities.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/testutilities/TestUtilities.java
deleted file mode 100644
index 5f778ecc..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/archive/testutilities/TestUtilities.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Created on Apr 3, 2003
- *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.jst.j2ee.archive.testutilities;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-/**
- * @author administrator
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class TestUtilities extends EcoreUtil {
- private static Map objectMap = new HashMap();
- private static Map subsetMap = new HashMap();
-
-
- /**
- * Returns the first collection member that {@link EClassifier#isInstance is an instance} of the type.
- * @param objects a collection of objects to check.
- * @param type the type of object to find.
- * @return the first object of the specified type.
- */
- public static Object getObjectByType(Resource res, EClassifier type, boolean isMany) {
- if (isMany)
- return getContainedCollectionByType(res.getContents(), type);
- else
- return getContainedObjectByType(res.getContents(), type);
- }
-
- public static Object getContainedObjectByType(List list, EClassifier type) {
- Object found;
- found = getObjectsByType(list, type);
- if (found != null && !((Collection)found).isEmpty())
- return extractObject((List) found,type);
-
- for (int i = 0; i < list.size(); i++) {
- EObject obj = (EObject) list.get(i);
- found = getContainedObjectByType(obj.eContents(), type);
- if (found != null)
- return found;
- }
-
- return null;
- }
-
- public static Object getContainedCollectionByType(List list, EClassifier type) {
- List found;
- found = (List)getObjectsByType(list, type);
- if (found != null && !found.isEmpty())
- return extractSubset(found, type);
-
- for (int i = 0; i < list.size(); i++) {
- EObject obj = (EObject) list.get(i);
- found = (List) getContainedCollectionByType(obj.eContents(), type);
- if (found != null)
- return found;
- }
-
- return null;
-
-
-
- }
-
- public static List extractSubset(List found, EClassifier type) {
- if (!subsetMap.containsKey(type)){
- subsetMap.put(type,new Integer(1));
- }
- int pos = ((Integer)subsetMap.get(type)).intValue();
-
- if (pos == found.size())
- pos = 1;
- List result = new ArrayList();
- for (int i = 0; i < pos; i++)
- result.add(found.get(i));
- pos++;
- subsetMap.put(type,new Integer(pos));
-
- return result;
- }
-
- public static Object extractObject(List found, EClassifier type) {
- if (!objectMap.containsKey(type)){
- objectMap.put(type,new Integer(0));
- }
- int pos = ((Integer)objectMap.get(type)).intValue();
-
- if (pos == found.size())
- pos = 0;
- Object holder = found.get(pos);
- pos++;
- objectMap.put(type,new Integer(pos));
-
- return holder;
- }
-
- public static void reset(){
- subsetMap.clear();
- objectMap.clear();
- }
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/core/tests/bvt/AutomatedBVT.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/core/tests/bvt/AutomatedBVT.java
deleted file mode 100644
index 740689a8..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/core/tests/bvt/AutomatedBVT.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Created on Apr 1, 2003
- *
- * To change this generated comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.jst.j2ee.core.tests.bvt;
-
-import java.net.URL;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jst.j2ee.archive.emftests.AllTests;
-
-
-/**
- * @author jsholl
- *
- * To change this generated comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class AutomatedBVT extends TestSuite {
-
- public static String baseDirectory = System.getProperty("user.dir") + java.io.File.separatorChar + "commonArchiveResources" + java.io.File.separatorChar;
-
- static {
- try {
- IPluginDescriptor pluginDescriptor = Platform.getPluginRegistry().getPluginDescriptor("org.eclipse.jst.j2ee.core.tests");
- URL url = pluginDescriptor.getInstallURL();
- AutomatedBVT.baseDirectory = Platform.asLocalURL(url).getFile() + "commonArchiveResources"+ java.io.File.separatorChar;
- } catch (Exception e) {
- System.err.println("Using working directory since a workspace URL could not be located.");
- }
- }
-
- public static int unimplementedMethods;
-
- public static void main(String[] args) {
- unimplementedMethods = 0;
- TestRunner.run(suite());
- if (unimplementedMethods > 0) {
- System.out.println("\nCalls to warnUnimpl: " + unimplementedMethods);
- }
- }
-
- public AutomatedBVT() {
- super();
- TestSuite suite = (TestSuite) AutomatedBVT.suite();
- for (int i = 0; i < suite.testCount(); i++) {
- addTest(suite.testAt(i));
- }
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite("Test for org.eclipse.jst.j2ee.core.bvt");
- //$JUnit-BEGIN$
- //TODO: Make the Archive Test Work
- // suite.addTest(AllArchiveTestsJava.suite());
- suite.addTest(AllTests.suite());
- //suite.addTest(AllJavaTestsJava.suite());
- //$JUnit-END$
- return suite;
- }
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/core/tests/bvt/AutomatedBVTEclipse.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/core/tests/bvt/AutomatedBVTEclipse.java
deleted file mode 100644
index 08b007d7..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/core/tests/bvt/AutomatedBVTEclipse.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Created on Mar 25, 2004
- *
- * To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package org.eclipse.jst.j2ee.core.tests.bvt;
-
-import java.io.IOException;
-import java.net.URL;
-
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.Platform;
-
-/**
- * @author jsholl
- *
- * To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-public class AutomatedBVTEclipse extends AutomatedBVT {
-
- public AutomatedBVTEclipse(){
- super();
- IPluginDescriptor pluginDescriptor = Platform.getPluginRegistry().getPluginDescriptor("org.eclipse.jst.j2ee.core.tests");
- URL url = pluginDescriptor.getInstallURL();
- try {
- AutomatedBVT.baseDirectory = Platform.asLocalURL(url).getFile() + "commonArchiveResources"+ java.io.File.separatorChar;
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-}
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/emfload/LoadJaxRPCMapOutsideWorkspace.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/emfload/LoadJaxRPCMapOutsideWorkspace.java
deleted file mode 100644
index 9aef4fbf..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/emfload/LoadJaxRPCMapOutsideWorkspace.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.emfload;
-
-import java.net.URL;
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.URIConverter;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.resource.impl.URIConverterImpl;
-import org.eclipse.jst.j2ee.common.internal.impl.J2EEResourceFactoryRegistry;
-import org.eclipse.jst.j2ee.internal.J2EEInit;
-import org.eclipse.jst.j2ee.webservice.jaxrpcmap.JaxrpcmapResource;
-import org.eclipse.jst.j2ee.webservice.jaxrpcmap.JaxrpcmapResourceFactory;
-import org.eclipse.wst.common.internal.emf.resource.EMF2DOMRendererFactory;
-
-
-public class LoadJaxRPCMapOutsideWorkspace extends TestCase {
-
- //public static String baseDirectory = System.getProperty("user.dir") + java.io.File.separatorChar + "testData" + java.io.File.separatorChar + "webservices" + java.io.File.separatorChar + "META-INF" + java.io.File.separatorChar;
-
- /**
- * <!-- begin-user-doc -->
- * Load all the argument file paths or URIs as instances of the model.
- * <!-- end-user-doc -->
- * @param args the file paths or URIs.
- * @generated
- */
- public void testLoadFile() throws Exception {
-
- IPluginDescriptor pluginDescriptor = Platform.getPluginRegistry().getPluginDescriptor("org.eclipse.jst.j2ee.core.tests");
- URL url = pluginDescriptor.getInstallURL();
- String baseDirectory = Platform.asLocalURL(url).getFile() + "testData" + java.io.File.separatorChar + "webservices" + java.io.File.separatorChar + "META-INF" + java.io.File.separatorChar;
-
- // Call J2EE Init();
-
- J2EEInit.init();
- // Create a resource set to hold the resources.
- //
- ResourceSet resourceSet = new ResourceSetImpl();
- J2EEResourceFactoryRegistry registry = new J2EEResourceFactoryRegistry();
- resourceSet.setResourceFactoryRegistry(registry);
- URIConverter conv = new URIConverterImpl();
- resourceSet.setURIConverter(conv);
- EMF2DOMRendererFactory.INSTANCE.setValidating(false);
-
- URI uri = URI.createFileURI(baseDirectory + "AnnuityServices_mapping.xml");
- registry.registerLastFileSegment(uri.lastSegment(), new JaxrpcmapResourceFactory(EMF2DOMRendererFactory.INSTANCE));
-
- try {
- // Demand load resource for this file.
- //
- JaxrpcmapResource jaxrpcmapRes = (JaxrpcmapResource)resourceSet.getResource(uri, true);
- System.out.println("Loaded " + uri);
- jaxrpcmapRes.getContents();
-
- }
- catch (RuntimeException exception) {
- System.out.println("Problem loading " + uri);
- exception.printStackTrace();
- }
- }
-/**
- * <!-- begin-user-doc -->
- * Prints diagnostics with indentation.
- * <!-- end-user-doc -->
- * @param diagnostic the diagnostic to print.
- * @param indent the indentation for printing.
- * @generated
- */
-protected static void printDiagnostic(Diagnostic diagnostic, String indent) {
- System.out.print(indent);
- System.out.println(diagnostic.getMessage());
- for (Iterator i = diagnostic.getChildren().iterator(); i.hasNext(); ) {
- printDiagnostic((Diagnostic)i.next(), indent + " ");
- }
-}
- }
-
-
-
diff --git a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/emfload/LoadWebServicesOutsideWorkspace.java b/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/emfload/LoadWebServicesOutsideWorkspace.java
deleted file mode 100644
index b518a643..00000000
--- a/tests/org.eclipse.jst.j2ee.core.tests/commonArchiveTests/org/eclipse/jst/j2ee/emfload/LoadWebServicesOutsideWorkspace.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.emfload;
-
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.URIConverter;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.resource.impl.URIConverterImpl;
-import org.eclipse.emf.ecore.util.Diagnostician;
-import org.eclipse.jst.j2ee.common.internal.impl.J2EEResourceFactoryRegistry;
-import org.eclipse.jst.j2ee.internal.J2EEInit;
-
-
-public class LoadWebServicesOutsideWorkspace extends TestCase {
- public static String baseDirectory = System.getProperty("user.dir") + java.io.File.separatorChar + "testData" + java.io.File.separatorChar + "webservices" + java.io.File.separatorChar + "META-INF" + java.io.File.separatorChar;
-
- /**
- * <!-- begin-user-doc -->
- * Load all the argument file paths or URIs as instances of the model.
- * <!-- end-user-doc -->
- * @param args the file paths or URIs.
- * @generated
- */
- public void testLoadFile() throws Exception {
-
- // Call J2EE Init();
-
- J2EEInit.init();
- // Create a resource set to hold the resources.
- //
- ResourceSet resourceSet = new ResourceSetImpl();
- resourceSet.setResourceFactoryRegistry(new J2EEResourceFactoryRegistry());
- URIConverter conv = new URIConverterImpl();
- resourceSet.setURIConverter(conv);
-
- URI uri = URI.createFileURI(baseDirectory + "webservices.xml");
-
- try {
- // Demand load resource for this file.
- //
- Resource resource = resourceSet.getResource(uri, true);
- System.out.println("Loaded " + uri);
-
- // Validate the contents of the loaded resource.
- //
- for (Iterator j = resource.getContents().iterator(); j.hasNext(); ) {
- EObject eObject = (EObject)j.next();
- Diagnostic diagnostic = Diagnostician.INSTANCE.validate(eObject);
- if (diagnostic.getSeverity() != Diagnostic.OK) {
- printDiagnostic(diagnostic, "");
- }
- }
- }
- catch (RuntimeException exception) {
- System.out.println("Problem loading " + uri);
- exception.printStackTrace();
- }
- }
-/**
- * <!-- begin-user-doc -->
- * Prints diagnostics with indentation.
- * <!-- end-user-doc -->
- * @param diagnostic the diagnostic to print.
- * @param indent the indentation for printing.
- * @generated
- */
-protected static void printDiagnostic(Diagnostic diagnostic, String indent) {
- System.out.print(indent);
- System.out.println(diagnostic.getMessage());
- for (Iterator i = diagnostic.getChildren().iterator(); i.hasNext(); ) {
- printDiagnostic((Diagnostic)i.next(), indent + " ");
- }
-}
- }
-
-
-

Back to the top