Split up the header tests to allow for more accurate reporting
Signed-off-by: Rob Stryker <stryker@redhat.com>
diff --git a/tests/org.eclipse.jst.j2ee.tests/DefectTestData/componentLoadAdapterTestData/testblah.war b/tests/org.eclipse.jst.j2ee.tests/DefectTestData/componentLoadAdapterTestData/testblah.war
index 92cf423..91b70d4 100644
--- a/tests/org.eclipse.jst.j2ee.tests/DefectTestData/componentLoadAdapterTestData/testblah.war
+++ b/tests/org.eclipse.jst.j2ee.tests/DefectTestData/componentLoadAdapterTestData/testblah.war
Binary files differ
diff --git a/tests/org.eclipse.jst.j2ee.tests/all/org/eclipse/jst/j2ee/tests/QuickSuite.java b/tests/org.eclipse.jst.j2ee.tests/all/org/eclipse/jst/j2ee/tests/QuickSuite.java
index 0f1567f..9a3e2c9 100644
--- a/tests/org.eclipse.jst.j2ee.tests/all/org/eclipse/jst/j2ee/tests/QuickSuite.java
+++ b/tests/org.eclipse.jst.j2ee.tests/all/org/eclipse/jst/j2ee/tests/QuickSuite.java
@@ -14,6 +14,7 @@
import org.eclipse.jst.jee.model.mergers.tests.ModelMergersSuite;
import org.eclipse.jst.jee.model.web.tests.WebModelSuite;
import org.eclipse.wtp.j2ee.headless.tests.exportmodel.ExportModelTest;
+import org.eclipse.wtp.j2ee.headless.tests.j2ee.headers.HeaderParserTests;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -40,6 +41,7 @@
addTest(ModelMergersSuite.suite());
addTest(WebModelSuite.suite());
+ addTest(HeaderParserTests.suite());
}
}
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/tests/bvt/CoreInfrastructureBVT.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/tests/bvt/CoreInfrastructureBVT.java
index 50b1e26..2ac57de 100644
--- a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/tests/bvt/CoreInfrastructureBVT.java
+++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/jst/j2ee/tests/bvt/CoreInfrastructureBVT.java
@@ -24,7 +24,7 @@
addTest(org.eclipse.jst.j2ee.classpath.tests.AllTests.suite());
addTest(org.eclipse.wtp.j2ee.headless.tests.web.container.WebAppLibrariesContainerTests.suite());
addTest(org.eclipse.jst.j2ee.defect.tests.DefectVerificationTestsSuite.suite());
- addTest(org.eclipse.wtp.j2ee.headless.tests.j2ee.operations.HeaderParserTests.suite());
+ addTest(org.eclipse.wtp.j2ee.headless.tests.j2ee.headers.HeaderParserTests.suite());
}
public static Test suite(){
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/j2ee/headers/Ear50ImportHeaderTest.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/j2ee/headers/Ear50ImportHeaderTest.java
new file mode 100644
index 0000000..0fe0e6a
--- /dev/null
+++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/j2ee/headers/Ear50ImportHeaderTest.java
@@ -0,0 +1,176 @@
+package org.eclipse.wtp.j2ee.headless.tests.j2ee.headers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
+import org.eclipse.jst.j2ee.internal.archive.JavaEEArchiveUtilities;
+import org.eclipse.jst.j2ee.webapplication.WebApp;
+import org.eclipse.jst.jee.archive.IArchive;
+import org.eclipse.jst.jee.archive.IArchiveResource;
+import org.eclipse.jst.jee.util.internal.JavaEEQuickPeek;
+import org.eclipse.wst.common.tests.ProjectUtility;
+import org.eclipse.wtp.j2ee.headless.tests.plugin.HeadlessTestsPlugin;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class Ear50ImportHeaderTest extends TestCase {
+ private static final String DATA_DIR = "TestData" + java.io.File.separatorChar + "headerParserTestData" + java.io.File.separatorChar;
+
+ protected String getDataPath(String shortName) throws Exception {
+ HeadlessTestsPlugin plugin = HeadlessTestsPlugin.getDefault();
+ String pluginRelativeFileName = DATA_DIR + java.io.File.separatorChar + shortName;
+ return ProjectUtility.getFullFileName(plugin, pluginRelativeFileName);
+ }
+
+ public static TestSuite suite() {
+ TestSuite suite = new TestSuite();
+
+ TestData earNoDD = new TestData("EAR5_NoDD.ear", J2EEVersionConstants.APPLICATION_TYPE, J2EEVersionConstants.JEE_5_0_ID, J2EEVersionConstants.JEE_5_0_ID,
+ org.eclipse.jst.javaee.application.Application.class,false);
+ ArrayList<TestData> data = noDD_Data();
+ Iterator<TestData> it = data.iterator();
+ TestData s = null;
+ while(it.hasNext()) {
+ s = it.next();
+ suite.addTest(new Ear50ImportHeaderTest(earNoDD, s));
+ }
+
+
+ TestData earWithDD = new TestData("EAR5_WithDD.ear", J2EEVersionConstants.APPLICATION_TYPE, J2EEVersionConstants.JEE_5_0_ID, J2EEVersionConstants.JEE_5_0_ID,
+ org.eclipse.jst.javaee.application.Application.class,true);
+ data = withDD_Data();
+ it = data.iterator();
+ s = null;
+ while(it.hasNext()) {
+ s = it.next();
+ suite.addTest(new Ear50ImportHeaderTest(earWithDD, s));
+ }
+ return suite;
+ }
+
+ private TestData earData;
+ private TestData testData;
+ public Ear50ImportHeaderTest(TestData ear, TestData testData) {
+ super("testEar50");
+ this.earData = ear;
+ this.testData = testData;
+ }
+
+
+ public void testEar50() throws Exception {
+ IArchive earArchive = null;
+
+ try {
+ String earLocation = getDataPath(earData.fileName);
+ IPath earPath = new Path(earLocation);
+ earArchive = JavaEEArchiveUtilities.INSTANCE.openArchive(earPath);
+ earArchive.getArchiveOptions().setOption(JavaEEArchiveUtilities.DISCRIMINATE_EJB_ANNOTATIONS, Boolean.TRUE);
+ JavaEEQuickPeek peek = JavaEEArchiveUtilities.INSTANCE.getJavaEEQuickPeek(earArchive);
+ Assert.assertEquals(earData.fileName + " type", earData.type, peek.getType());
+ if (earData.deploymentDescriptor){
+ Assert.assertEquals(earData.fileName + " mod version", earData.modVersion, peek.getVersion());
+ Assert.assertEquals(earData.fileName + " ee version", earData.eeVersion, peek.getJavaEEVersion());
+ }
+ else{
+ Assert.assertTrue(earData.fileName + " mod version", peek.getVersion() >= earData.modVersion);
+ Assert.assertTrue(earData.fileName + " ee version", peek.getJavaEEVersion() >= earData.eeVersion);
+ }
+ IArchiveResource innerArchiveResource;
+ IArchive innerArchive = null;
+ innerArchiveResource = earArchive.getArchiveResource(new Path(testData.fileName));
+ innerArchive = earArchive.getNestedArchive(innerArchiveResource);
+ peek = JavaEEArchiveUtilities.INSTANCE.getJavaEEQuickPeek(innerArchive);
+ Assert.assertEquals(testData.fileName + " type", testData.type, peek.getType());
+ Assert.assertEquals(testData.fileName + " mod version", testData.modVersion, peek.getVersion());
+ Assert.assertEquals(testData.fileName + " ee version", testData.eeVersion, peek.getJavaEEVersion());
+
+ //TODO uncomment this block when this bug is resolved: https://bugs.eclipse.org/bugs/show_bug.cgi?id=199953
+// System.err.println("TODO -- can't getModelObject from inner archive of JEE5 EAR");
+// System.err.println(" -- see https://bugs.eclipse.org/bugs/show_bug.cgi?id=199953");
+// Object modelObject = innerArchive.getModelObject();
+// Class clazz = modelObject.getClass();
+// boolean foundInterface = false;
+// for (Class anInterface : clazz.getInterfaces()) {
+// if (!foundInterface) {
+// foundInterface = anInterface == testData.modelObjectInterface;
+// }
+// }
+// Assert.assertTrue("Returned Model Object: " + modelObject.getClass().getName() + " does not implement " + testData.modelObjectInterface.getName(), foundInterface);
+ } finally {
+ if(earArchive != null) {
+ JavaEEArchiveUtilities.INSTANCE.closeArchive(earArchive);
+ }
+ }
+ }
+
+
+ private static ArrayList<TestData> noDD_Data() {
+ ArrayList<TestData> nestedArchiveData = new ArrayList<TestData>();
+ nestedArchiveData.add(new TestData("application-client12.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.J2EE_1_2_ID, J2EEVersionConstants.J2EE_1_2_ID,
+ org.eclipse.jst.j2ee.client.ApplicationClient.class));
+ nestedArchiveData.add(new TestData("application-client13.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.J2EE_1_3_ID, J2EEVersionConstants.J2EE_1_3_ID,
+ org.eclipse.jst.j2ee.client.ApplicationClient.class));
+ nestedArchiveData.add(new TestData("application-client14.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.J2EE_1_4_ID, J2EEVersionConstants.J2EE_1_4_ID,
+ org.eclipse.jst.j2ee.client.ApplicationClient.class));
+// nestedArchiveData.add(new TestData("AppClient5_NoDD.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.JEE_5_0_ID, J2EEVersionConstants.JEE_5_0_ID,
+// org.eclipse.jst.javaee.applicationclient.ApplicationClient.class));
+ nestedArchiveData.add(new TestData("AppClient5_WithDD.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.JEE_5_0_ID, J2EEVersionConstants.JEE_5_0_ID,
+ org.eclipse.jst.javaee.applicationclient.ApplicationClient.class));
+
+ nestedArchiveData.add(new TestData("ejb-jar11.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_1_1_ID, J2EEVersionConstants.J2EE_1_2_ID, org.eclipse.jst.j2ee.ejb.EJBJar.class));
+ nestedArchiveData.add(new TestData("ejb-jar20.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_2_0_ID, J2EEVersionConstants.J2EE_1_3_ID, org.eclipse.jst.j2ee.ejb.EJBJar.class));
+ nestedArchiveData.add(new TestData("ejb-jar21.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_2_1_ID, J2EEVersionConstants.J2EE_1_4_ID, org.eclipse.jst.j2ee.ejb.EJBJar.class));
+// nestedArchiveData.add(new TestData("EJB3_NoDD_MessageDriven.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_3_0_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.ejb.EJBJar.class));
+// nestedArchiveData.add(new TestData("EJB3_NoDD_Stateful.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_3_0_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.ejb.EJBJar.class));
+// nestedArchiveData.add(new TestData("EJB3_NoDD_Stateless.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_3_0_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.ejb.EJBJar.class));
+ nestedArchiveData.add(new TestData("EJB3_WithDD.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_3_0_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.ejb.EJBJar.class));
+
+ nestedArchiveData.add(new TestData("ra10.rar", J2EEVersionConstants.CONNECTOR_TYPE, J2EEVersionConstants.JCA_1_0_ID, J2EEVersionConstants.J2EE_1_3_ID, org.eclipse.jst.j2ee.jca.Connector.class));
+ nestedArchiveData.add(new TestData("ra15.rar", J2EEVersionConstants.CONNECTOR_TYPE, J2EEVersionConstants.JCA_1_5_ID, J2EEVersionConstants.J2EE_1_4_ID, org.eclipse.jst.j2ee.jca.Connector.class));
+
+ nestedArchiveData.add(new TestData("web22.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_2_ID, J2EEVersionConstants.J2EE_1_2_ID, WebApp.class));
+ nestedArchiveData.add(new TestData("web23.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_3_ID, J2EEVersionConstants.J2EE_1_3_ID, WebApp.class));
+ nestedArchiveData.add(new TestData("web24.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_4_ID, J2EEVersionConstants.J2EE_1_4_ID, WebApp.class));
+// nestedArchiveData.add(new TestData("Web25_NoDD.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_5_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.web.WebApp.class));
+ nestedArchiveData.add(new TestData("Web25_WithDD.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_5_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.web.WebApp.class));
+ return nestedArchiveData;
+ }
+
+
+ private static ArrayList<TestData> withDD_Data() {
+ ArrayList<TestData> nestedArchiveData = new ArrayList<TestData>();
+ nestedArchiveData.add(new TestData("application-client12.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.J2EE_1_2_ID, J2EEVersionConstants.J2EE_1_2_ID,
+ org.eclipse.jst.j2ee.client.ApplicationClient.class));
+ nestedArchiveData.add(new TestData("application-client13.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.J2EE_1_3_ID, J2EEVersionConstants.J2EE_1_3_ID,
+ org.eclipse.jst.j2ee.client.ApplicationClient.class));
+ nestedArchiveData.add(new TestData("application-client14.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.J2EE_1_4_ID, J2EEVersionConstants.J2EE_1_4_ID,
+ org.eclipse.jst.j2ee.client.ApplicationClient.class));
+// nestedArchiveData.add(new TestData("AppClient5_NoDD.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.JEE_5_0_ID, J2EEVersionConstants.JEE_5_0_ID,
+// org.eclipse.jst.javaee.applicationclient.ApplicationClient.class));
+ nestedArchiveData.add(new TestData("AppClient5_WithDD.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.JEE_5_0_ID, J2EEVersionConstants.JEE_5_0_ID,
+ org.eclipse.jst.javaee.applicationclient.ApplicationClient.class));
+
+ nestedArchiveData.add(new TestData("ejb-jar11.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_1_1_ID, J2EEVersionConstants.J2EE_1_2_ID, org.eclipse.jst.j2ee.ejb.EJBJar.class));
+ nestedArchiveData.add(new TestData("ejb-jar20.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_2_0_ID, J2EEVersionConstants.J2EE_1_3_ID, org.eclipse.jst.j2ee.ejb.EJBJar.class));
+ nestedArchiveData.add(new TestData("ejb-jar21.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_2_1_ID, J2EEVersionConstants.J2EE_1_4_ID, org.eclipse.jst.j2ee.ejb.EJBJar.class));
+// nestedArchiveData.add(new TestData("EJB3_NoDD_MessageDriven.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_3_0_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.ejb.EJBJar.class));
+// nestedArchiveData.add(new TestData("EJB3_NoDD_Stateful.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_3_0_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.ejb.EJBJar.class));
+// nestedArchiveData.add(new TestData("EJB3_NoDD_Stateless.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_3_0_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.ejb.EJBJar.class));
+ nestedArchiveData.add(new TestData("EJB3_WithDD.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_3_0_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.ejb.EJBJar.class));
+
+ nestedArchiveData.add(new TestData("ra10.rar", J2EEVersionConstants.CONNECTOR_TYPE, J2EEVersionConstants.JCA_1_0_ID, J2EEVersionConstants.J2EE_1_3_ID, org.eclipse.jst.j2ee.jca.Connector.class));
+ nestedArchiveData.add(new TestData("ra15.rar", J2EEVersionConstants.CONNECTOR_TYPE, J2EEVersionConstants.JCA_1_5_ID, J2EEVersionConstants.J2EE_1_4_ID, org.eclipse.jst.j2ee.jca.Connector.class));
+
+ nestedArchiveData.add(new TestData("web22.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_2_ID, J2EEVersionConstants.J2EE_1_2_ID, WebApp.class));
+ nestedArchiveData.add(new TestData("web23.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_3_ID, J2EEVersionConstants.J2EE_1_3_ID, WebApp.class));
+ nestedArchiveData.add(new TestData("web24.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_4_ID, J2EEVersionConstants.J2EE_1_4_ID, WebApp.class));
+// nestedArchiveData.add(new TestData("Web25_NoDD.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_5_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.web.WebApp.class));
+ nestedArchiveData.add(new TestData("Web25_WithDD.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_5_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.web.WebApp.class));
+ return nestedArchiveData;
+ }
+}
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/j2ee/headers/HeaderParserTests.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/j2ee/headers/HeaderParserTests.java
new file mode 100644
index 0000000..579a0d4
--- /dev/null
+++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/j2ee/headers/HeaderParserTests.java
@@ -0,0 +1,38 @@
+package org.eclipse.wtp.j2ee.headless.tests.j2ee.headers;
+
+import org.eclipse.jst.jee.util.internal.JavaEEQuickPeek;
+import org.eclipse.wst.common.tests.BaseTestCase;
+import org.eclipse.wst.common.tests.ProjectUtility;
+import org.eclipse.wtp.j2ee.headless.tests.plugin.HeadlessTestsPlugin;
+
+import junit.framework.Assert;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class HeaderParserTests extends BaseTestCase {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ suite.addTestSuite(HeaderParserTests.class);
+ suite.addTest(Ear50ImportHeaderTest.suite());
+ suite.addTest(JEEFromArchiveHeaderTest.suite());
+ suite.addTest(NormalizeSchemaLocationTest.suite());
+ suite.addTest(XMLHeaderTest.suite());
+ return suite;
+ }
+
+ private static final String DATA_DIR = "TestData" + java.io.File.separatorChar + "headerParserTestData" + java.io.File.separatorChar;
+
+ protected String getDataPath(String shortName) throws Exception {
+ HeadlessTestsPlugin plugin = HeadlessTestsPlugin.getDefault();
+ String pluginRelativeFileName = DATA_DIR + java.io.File.separatorChar + shortName;
+ return ProjectUtility.getFullFileName(plugin, pluginRelativeFileName);
+ }
+
+ public void testNull() throws Exception {
+ JavaEEQuickPeek quickPeek = new JavaEEQuickPeek(null);
+ Assert.assertEquals(JavaEEQuickPeek.UNKNOWN, quickPeek.getType());
+ Assert.assertEquals(JavaEEQuickPeek.UNKNOWN, quickPeek.getVersion());
+ Assert.assertEquals(JavaEEQuickPeek.UNKNOWN, quickPeek.getJavaEEVersion());
+ }
+}
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/j2ee/headers/JEEFromArchiveHeaderTest.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/j2ee/headers/JEEFromArchiveHeaderTest.java
new file mode 100644
index 0000000..576a6df
--- /dev/null
+++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/j2ee/headers/JEEFromArchiveHeaderTest.java
@@ -0,0 +1,114 @@
+package org.eclipse.wtp.j2ee.headless.tests.j2ee.headers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
+import org.eclipse.jst.j2ee.internal.archive.JavaEEArchiveUtilities;
+import org.eclipse.jst.j2ee.webapplication.WebApp;
+import org.eclipse.jst.jee.archive.IArchive;
+import org.eclipse.jst.jee.util.internal.JavaEEQuickPeek;
+import org.eclipse.wst.common.tests.ProjectUtility;
+import org.eclipse.wtp.j2ee.headless.tests.plugin.HeadlessTestsPlugin;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class JEEFromArchiveHeaderTest extends TestCase {
+ private static final String DATA_DIR = "TestData" + java.io.File.separatorChar + "headerParserTestData" + java.io.File.separatorChar;
+
+ protected String getDataPath(String shortName) throws Exception {
+ HeadlessTestsPlugin plugin = HeadlessTestsPlugin.getDefault();
+ String pluginRelativeFileName = DATA_DIR + java.io.File.separatorChar + shortName;
+ return ProjectUtility.getFullFileName(plugin, pluginRelativeFileName);
+ }
+
+ public static TestSuite suite() {
+ TestSuite suite = new TestSuite();
+ ArrayList<TestData> data = getTestData();
+ Iterator<TestData> it = data.iterator();
+ TestData s = null;
+ while(it.hasNext()) {
+ s = it.next();
+ suite.addTest(new JEEFromArchiveHeaderTest(s));
+ }
+ return suite;
+ }
+
+ private TestData td;
+ public JEEFromArchiveHeaderTest(TestData td) {
+ super("testJavaEEFromArchive");
+ this.td = td;
+ }
+
+
+
+
+ private static ArrayList<TestData> getTestData() {
+ ArrayList<TestData> data = new ArrayList<TestData>();
+ data.add(new TestData("application-client12.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.J2EE_1_2_ID, J2EEVersionConstants.J2EE_1_2_ID,
+ org.eclipse.jst.j2ee.client.ApplicationClient.class));
+ data.add(new TestData("application-client13.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.J2EE_1_3_ID, J2EEVersionConstants.J2EE_1_3_ID,
+ org.eclipse.jst.j2ee.client.ApplicationClient.class));
+ data.add(new TestData("application-client14.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.J2EE_1_4_ID, J2EEVersionConstants.J2EE_1_4_ID,
+ org.eclipse.jst.j2ee.client.ApplicationClient.class));
+ data.add(new TestData("application-client5.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.JEE_5_0_ID, J2EEVersionConstants.JEE_5_0_ID,
+ org.eclipse.jst.javaee.applicationclient.ApplicationClient.class));
+
+ data.add(new TestData("application12.ear", J2EEVersionConstants.APPLICATION_TYPE, J2EEVersionConstants.J2EE_1_2_ID, J2EEVersionConstants.J2EE_1_2_ID,
+ org.eclipse.jst.j2ee.application.Application.class));
+ data.add(new TestData("application13.ear", J2EEVersionConstants.APPLICATION_TYPE, J2EEVersionConstants.J2EE_1_3_ID, J2EEVersionConstants.J2EE_1_3_ID,
+ org.eclipse.jst.j2ee.application.Application.class));
+ data.add(new TestData("application14.ear", J2EEVersionConstants.APPLICATION_TYPE, J2EEVersionConstants.J2EE_1_4_ID, J2EEVersionConstants.J2EE_1_4_ID,
+ org.eclipse.jst.j2ee.application.Application.class));
+ data.add(new TestData("application5.ear", J2EEVersionConstants.APPLICATION_TYPE, J2EEVersionConstants.JEE_5_0_ID, J2EEVersionConstants.JEE_5_0_ID,
+ org.eclipse.jst.javaee.application.Application.class));
+
+ data.add(new TestData("ejb-jar11.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_1_1_ID, J2EEVersionConstants.J2EE_1_2_ID, org.eclipse.jst.j2ee.ejb.EJBJar.class));
+ data.add(new TestData("ejb-jar20.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_2_0_ID, J2EEVersionConstants.J2EE_1_3_ID, org.eclipse.jst.j2ee.ejb.EJBJar.class));
+ data.add(new TestData("ejb-jar21.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_2_1_ID, J2EEVersionConstants.J2EE_1_4_ID, org.eclipse.jst.j2ee.ejb.EJBJar.class));
+ data.add(new TestData("ejb-jar30.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_3_0_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.ejb.EJBJar.class));
+
+ data.add(new TestData("ra10.rar", J2EEVersionConstants.CONNECTOR_TYPE, J2EEVersionConstants.JCA_1_0_ID, J2EEVersionConstants.J2EE_1_3_ID, org.eclipse.jst.j2ee.jca.Connector.class));
+ data.add(new TestData("ra15.rar", J2EEVersionConstants.CONNECTOR_TYPE, J2EEVersionConstants.JCA_1_5_ID, J2EEVersionConstants.J2EE_1_4_ID, org.eclipse.jst.j2ee.jca.Connector.class));
+
+ data.add(new TestData("web22.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_2_ID, J2EEVersionConstants.J2EE_1_2_ID, WebApp.class));
+ data.add(new TestData("web23.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_3_ID, J2EEVersionConstants.J2EE_1_3_ID, WebApp.class));
+ data.add(new TestData("web24.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_4_ID, J2EEVersionConstants.J2EE_1_4_ID, WebApp.class));
+ data.add(new TestData("web25.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_5_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.web.WebApp.class));
+ return data;
+ }
+
+ public void testJavaEEFromArchive() throws Exception {
+ IArchive archive = null;
+ try {
+ TestData testData = td;
+ String fileLocation = getDataPath(testData.fileName);
+ IPath filePath = new Path(fileLocation);
+ archive = JavaEEArchiveUtilities.INSTANCE.openArchive(filePath);
+ JavaEEQuickPeek peek = JavaEEArchiveUtilities.INSTANCE.getJavaEEQuickPeek(archive);
+ Assert.assertEquals(testData.type, peek.getType());
+ Assert.assertEquals(testData.modVersion, peek.getVersion());
+ Assert.assertEquals(testData.eeVersion, peek.getJavaEEVersion());
+
+ Object modelObject = archive.getModelObject();
+ Class clazz = modelObject.getClass();
+ boolean foundInterface = false;
+ for (Class anInterface : clazz.getInterfaces()) {
+ if (!foundInterface) {
+ foundInterface = anInterface == testData.modelObjectInterface;
+ }
+ }
+ Assert.assertTrue("Returned Model Object: " + modelObject.getClass().getName() + " does not implement " + testData.modelObjectInterface.getName(), foundInterface);
+ } finally {
+ if (archive != null) {
+ JavaEEArchiveUtilities.INSTANCE.closeArchive(archive);
+ }
+ }
+ }
+
+
+}
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/j2ee/headers/NormalizeSchemaLocationTest.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/j2ee/headers/NormalizeSchemaLocationTest.java
new file mode 100644
index 0000000..033d70a
--- /dev/null
+++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/j2ee/headers/NormalizeSchemaLocationTest.java
@@ -0,0 +1,106 @@
+package org.eclipse.wtp.j2ee.headless.tests.j2ee.headers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.jst.jee.util.internal.JavaEEQuickPeek;
+import org.junit.Test;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class NormalizeSchemaLocationTest extends TestCase {
+
+ public static TestSuite suite() {
+ TestSuite suite = new TestSuite();
+ ArrayList<String[]> data = createData();
+ Iterator<String[]> it = data.iterator();
+ String[] s = null;
+ while(it.hasNext()) {
+ s = it.next();
+ suite.addTest(new NormalizeSchemaLocationTest(s[0], s[1]));
+ }
+ return suite;
+ }
+
+ private static ArrayList<String[]> createData() {
+ ArrayList<String[]> list = new ArrayList<String[]>();
+ list.add(new String[] {"", ""});
+ list.add(new String[] {"", " "});
+ list.add(new String[] {"", " "});
+ list.add(new String[] {"", " "});
+ list.add(new String[] {"", "\n"});
+ list.add(new String[] {"", "\n\n"});
+ list.add(new String[] {"", "\n\n\n"});
+ list.add(new String[] {"", "\n "});
+ list.add(new String[] {"simple", "simple"});
+ list.add(new String[] {"simple", "simple "});
+ list.add(new String[] {"simple", "simple "});
+ list.add(new String[] {"simple", "simple "});
+ list.add(new String[] {"simple", " simple"});
+ list.add(new String[] {"simple", " simple "});
+ list.add(new String[] {"simple", "simple\n"});
+ list.add(new String[] {"simple", "\nsimple\n"});
+ list.add(new String[] {"simple", "simple\r"});
+ list.add(new String[] {"simple", "simple\t"});
+ list.add(new String[] {"simple", "simple\n\n"});
+ list.add(new String[] {"simple", "simple\n\r"});
+ list.add(new String[] {"simple", "simple\n\t"});
+ list.add(new String[] {"simple", "simple \n"});
+ list.add(new String[] {"simple", "simple\r "});
+ list.add(new String[] {"simple", " \t\tsimple\t"});
+ list.add(new String[] {"simple", "simple\n \n"});
+ list.add(new String[] {"simple", "\r \rsimple \n\r"});
+ list.add(new String[] {"simple", " simple\n\t"});
+
+ list.add(new String[] {"simple simple", "simple simple"});
+ list.add(new String[] {"simple simple", "simple simple"});
+ list.add(new String[] {"simple simple", "simple\nsimple"});
+ list.add(new String[] {"simple simple", "simple\rsimple"});
+ list.add(new String[] {"simple simple", "simple\tsimple"});
+ list.add(new String[] {"simple simple", "simple \nsimple"});
+ list.add(new String[] {"simple simple", "simple\r simple"});
+ list.add(new String[] {"simple simple", "simple \t simple"});
+ list.add(new String[] {"simple simple", "simple simple "});
+ list.add(new String[] {"simple simple", " simple simple"});
+ list.add(new String[] {"simple simple", " simple simple "});
+ list.add(new String[] {"simple simple", "simple\n simple\n"});
+ list.add(new String[] {"simple simple", "simple\r simple\r"});
+ list.add(new String[] {"simple simple", "simple\t simple\t"});
+ list.add(new String[] {"simple simple", "simple\n\nsimple"});
+ list.add(new String[] {"simple simple", "simple\n\rsimple\n\n"});
+ list.add(new String[] {"simple simple", "simple\n\tsimple\n\t"});
+ list.add(new String[] {"simple simple", "simple \nsimple \n"});
+ list.add(new String[] {"simple simple", "simple\r simple\r "});
+ list.add(new String[] {"simple simple", " \t\tsimple\t \t\tsimple\t"});
+ list.add(new String[] {"simple simple", "simple\n \nsimple\n \n"});
+ list.add(new String[] {"simple simple", "\r \rsimple \n\r\r \rsimple \n\r"});
+ list.add(new String[] {"simple simple", " simple\n\t simple\n\t"});
+ return list;
+ }
+
+
+ private String normalizedSchemaLocation;
+ private String someSchemaLocation;
+ public NormalizeSchemaLocationTest(String normalizedSchemaLocation, String someSchemaLocation) {
+ super("testNormalizeSchemaLocation");
+ this.normalizedSchemaLocation = normalizedSchemaLocation;
+ this.someSchemaLocation = someSchemaLocation;
+ }
+
+ @Test
+ public void testNormalizeSchemaLocation() throws Exception {
+ verifyNormalizeSchemaLocation(normalizedSchemaLocation, someSchemaLocation);
+ }
+
+ private String verifyNormalizeSchemaLocation(String normalizedSchemaLocation, String someSchemaLocation) {
+ String normalizedString = JavaEEQuickPeek.normalizeSchemaLocation(someSchemaLocation);
+ if(!normalizedSchemaLocation.equals(normalizedString)){
+ Assert.assertEquals(normalizedSchemaLocation, normalizedString);
+ }
+ return normalizedString;
+ }
+
+
+}
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/j2ee/headers/TestData.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/j2ee/headers/TestData.java
new file mode 100644
index 0000000..7669d00
--- /dev/null
+++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/j2ee/headers/TestData.java
@@ -0,0 +1,36 @@
+package org.eclipse.wtp.j2ee.headless.tests.j2ee.headers;
+
+class TestData {
+ String fileName;
+
+ int type;
+
+ int modVersion;
+
+ int eeVersion;
+
+ boolean deploymentDescriptor;
+
+ Class modelObjectInterface;
+
+ public TestData(String fileName, int type, int modVersion, int eeVersion) {
+ this.fileName = fileName;
+ this.type = type;
+ this.modVersion = modVersion;
+ this.eeVersion = eeVersion;
+ }
+
+ public TestData(String fileName, int type, int modVersion, int eeVersion, Class modelTypeClass) {
+ this(fileName, type, modVersion, eeVersion);
+ this.modelObjectInterface = modelTypeClass;
+ }
+
+ public TestData(String fileName, int type, int modVersion, int eeVersion, Class modelTypeClass,boolean deploymentDescriptor) {
+ this(fileName, type, modVersion, eeVersion,modelTypeClass);
+ this.deploymentDescriptor = deploymentDescriptor;
+ }
+
+ public String toString() {
+ return fileName + " - " + type + " - " + modVersion + " - " + eeVersion + " - " + deploymentDescriptor + " - " + deploymentDescriptor;
+ }
+}
\ No newline at end of file
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/j2ee/headers/XMLHeaderTest.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/j2ee/headers/XMLHeaderTest.java
new file mode 100644
index 0000000..2b4ccba
--- /dev/null
+++ b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/j2ee/headers/XMLHeaderTest.java
@@ -0,0 +1,124 @@
+package org.eclipse.wtp.j2ee.headless.tests.j2ee.headers;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
+import org.eclipse.jst.jee.util.internal.JavaEEQuickPeek;
+import org.eclipse.wst.common.tests.ProjectUtility;
+import org.eclipse.wtp.j2ee.headless.tests.plugin.HeadlessTestsPlugin;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class XMLHeaderTest extends TestCase {
+ private static final String DATA_DIR = "TestData" + java.io.File.separatorChar + "headerParserTestData" + java.io.File.separatorChar;
+
+ protected String getDataPath(String shortName) throws Exception {
+ HeadlessTestsPlugin plugin = HeadlessTestsPlugin.getDefault();
+ String pluginRelativeFileName = DATA_DIR + java.io.File.separatorChar + shortName;
+ return ProjectUtility.getFullFileName(plugin, pluginRelativeFileName);
+ }
+
+ public static TestSuite suite() {
+ TestSuite suite = new TestSuite();
+ ArrayList<TestData> data = getXMLData();
+ Iterator<TestData> it = data.iterator();
+ TestData s = null;
+ while(it.hasNext()) {
+ s = it.next();
+ suite.addTest(new XMLHeaderTest(s));
+ }
+ return suite;
+ }
+
+ private TestData td;
+ public XMLHeaderTest(TestData td) {
+ super("testJavaEE");
+ this.td = td;
+ }
+
+ public void testJavaEE() throws Exception {
+ InputStream in = null;
+ try {
+ TestData testData = td;
+ in = new FileInputStream(new File(getDataPath(testData.fileName)));
+ JavaEEQuickPeek peek = new JavaEEQuickPeek(in);
+ Assert.assertEquals("type does not match: " + testData.toString(), testData.type, peek.getType());
+ Assert.assertEquals("modVersion does not match: " + testData.toString(), testData.modVersion, peek.getVersion());
+ Assert.assertEquals("eeVersion does not match: " + testData.toString(), testData.eeVersion, peek.getJavaEEVersion());
+ } finally {
+ if (in != null) {
+ in.close();
+ }
+ }
+ }
+
+ private static ArrayList<TestData> getXMLData() {
+ ArrayList<TestData> data = new ArrayList<TestData>();
+ data.add(new TestData("application-client12.xml", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.J2EE_1_2_ID, J2EEVersionConstants.J2EE_1_2_ID));
+ data.add(new TestData("application-client13.xml", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.J2EE_1_3_ID, J2EEVersionConstants.J2EE_1_3_ID));
+ data.add(new TestData("application-client14.xml", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.J2EE_1_4_ID, J2EEVersionConstants.J2EE_1_4_ID));
+ data.add(new TestData("application-client5.xml", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.JEE_5_0_ID, J2EEVersionConstants.JEE_5_0_ID));
+
+ data.add(new TestData("application12.xml", J2EEVersionConstants.APPLICATION_TYPE, J2EEVersionConstants.J2EE_1_2_ID, J2EEVersionConstants.J2EE_1_2_ID));
+ data.add(new TestData("application13.xml", J2EEVersionConstants.APPLICATION_TYPE, J2EEVersionConstants.J2EE_1_3_ID, J2EEVersionConstants.J2EE_1_3_ID));
+ data.add(new TestData("application14.xml", J2EEVersionConstants.APPLICATION_TYPE, J2EEVersionConstants.J2EE_1_4_ID, J2EEVersionConstants.J2EE_1_4_ID));
+ data.add(new TestData("application5.xml", J2EEVersionConstants.APPLICATION_TYPE, J2EEVersionConstants.JEE_5_0_ID, J2EEVersionConstants.JEE_5_0_ID));
+
+ data.add(new TestData("ejb-jar11.xml", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_1_1_ID, J2EEVersionConstants.J2EE_1_2_ID));
+ data.add(new TestData("ejb-jar20.xml", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_2_0_ID, J2EEVersionConstants.J2EE_1_3_ID));
+ data.add(new TestData("ejb-jar21.xml", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_2_1_ID, J2EEVersionConstants.J2EE_1_4_ID));
+ data.add(new TestData("ejb-jar30.xml", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_3_0_ID, J2EEVersionConstants.JEE_5_0_ID));
+
+ data.add(new TestData("ra10.xml", J2EEVersionConstants.CONNECTOR_TYPE, J2EEVersionConstants.JCA_1_0_ID, J2EEVersionConstants.J2EE_1_3_ID));
+ data.add(new TestData("ra15.xml", J2EEVersionConstants.CONNECTOR_TYPE, J2EEVersionConstants.JCA_1_5_ID, J2EEVersionConstants.J2EE_1_4_ID));
+
+ data.add(new TestData("web22.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_2_ID, J2EEVersionConstants.J2EE_1_2_ID));
+ data.add(new TestData("web23.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_3_ID, J2EEVersionConstants.J2EE_1_3_ID));
+ data.add(new TestData("web24.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_4_ID, J2EEVersionConstants.J2EE_1_4_ID));
+ data.add(new TestData("web25.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_5_ID, J2EEVersionConstants.JEE_5_0_ID));
+ data.add(new TestData("web30.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_3_0_ID, J2EEVersionConstants.JEE_6_0_ID));
+ data.add(new TestData("web31.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_3_1_ID, J2EEVersionConstants.JEE_7_0_ID));
+ data.add(new TestData("web40.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_4_0_ID, J2EEVersionConstants.JEE_8_0_ID));
+
+ // Test the Web-App DDs without the schema specified
+
+ // Following tests fail
+// data.add(new TestData("web24min.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_4_ID, J2EEVersionConstants.J2EE_1_4_ID));
+// data.add(new TestData("web25min.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_5_ID, J2EEVersionConstants.JEE_5_0_ID));
+// data.add(new TestData("web30min.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_3_0_ID, J2EEVersionConstants.JEE_6_0_ID));
+// data.add(new TestData("web31min.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_3_1_ID, J2EEVersionConstants.JEE_7_0_ID));
+// data.add(new TestData("web40min.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_4_0_ID, J2EEVersionConstants.JEE_8_0_ID));
+
+ // test some bogus dds as well
+ data.add(new TestData("notxml.xml", J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
+ data.add(new TestData("notjavaee.xml", J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
+
+ data.add(new TestData("application-client0.xml", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
+ data.add(new TestData("application-client00.xml", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
+ data.add(new TestData("application-client000.xml", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
+
+ data.add(new TestData("application0.xml", J2EEVersionConstants.APPLICATION_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
+ data.add(new TestData("application00.xml", J2EEVersionConstants.APPLICATION_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
+ data.add(new TestData("application000.xml", J2EEVersionConstants.APPLICATION_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
+
+ data.add(new TestData("ejb-jar0.xml", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
+ data.add(new TestData("ejb-jar00.xml", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
+ data.add(new TestData("ejb-jar000.xml", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
+
+ data.add(new TestData("ra0.xml", J2EEVersionConstants.CONNECTOR_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
+ data.add(new TestData("ra00.xml", J2EEVersionConstants.CONNECTOR_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
+ data.add(new TestData("ra000.xml", J2EEVersionConstants.CONNECTOR_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
+
+ data.add(new TestData("web0.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
+ data.add(new TestData("web00.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
+ data.add(new TestData("web000.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
+ return data;
+ }
+
+}
diff --git a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/j2ee/operations/HeaderParserTests.java b/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/j2ee/operations/HeaderParserTests.java
deleted file mode 100644
index eaf4e0c..0000000
--- a/tests/org.eclipse.jst.j2ee.tests/j2ee-tests/org/eclipse/wtp/j2ee/headless/tests/j2ee/operations/HeaderParserTests.java
+++ /dev/null
@@ -1,406 +0,0 @@
-package org.eclipse.wtp.j2ee.headless.tests.j2ee.operations;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
-import org.eclipse.jst.j2ee.internal.archive.JavaEEArchiveUtilities;
-import org.eclipse.jst.j2ee.webapplication.WebApp;
-import org.eclipse.jst.jee.archive.IArchive;
-import org.eclipse.jst.jee.archive.IArchiveResource;
-import org.eclipse.jst.jee.util.internal.JavaEEQuickPeek;
-import org.eclipse.wst.common.tests.AssertWarn;
-import org.eclipse.wst.common.tests.BaseTestCase;
-import org.eclipse.wst.common.tests.ProjectUtility;
-import org.eclipse.wtp.j2ee.headless.tests.plugin.HeadlessTestsPlugin;
-
-public class HeaderParserTests extends BaseTestCase {
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTestSuite(HeaderParserTests.class);
- return suite;
- }
-
- private static final String DATA_DIR = "TestData" + java.io.File.separatorChar + "headerParserTestData" + java.io.File.separatorChar;
-
- protected String getDataPath(String shortName) throws Exception {
- HeadlessTestsPlugin plugin = HeadlessTestsPlugin.getDefault();
- String pluginRelativeFileName = DATA_DIR + java.io.File.separatorChar + shortName;
- return ProjectUtility.getFullFileName(plugin, pluginRelativeFileName);
- }
-
- private class TestData {
- String fileName;
-
- int type;
-
- int modVersion;
-
- int eeVersion;
-
- boolean deploymentDescriptor;
-
- Class modelObjectInterface;
-
- public TestData(String fileName, int type, int modVersion, int eeVersion) {
- this.fileName = fileName;
- this.type = type;
- this.modVersion = modVersion;
- this.eeVersion = eeVersion;
- }
-
- public TestData(String fileName, int type, int modVersion, int eeVersion, Class modelTypeClass) {
- this(fileName, type, modVersion, eeVersion);
- this.modelObjectInterface = modelTypeClass;
- }
-
- public TestData(String fileName, int type, int modVersion, int eeVersion, Class modelTypeClass,boolean deploymentDescriptor) {
- this(fileName, type, modVersion, eeVersion,modelTypeClass);
- this.deploymentDescriptor = deploymentDescriptor;
- }
- }
-
- public void testNull() throws Exception {
- JavaEEQuickPeek quickPeek = new JavaEEQuickPeek(null);
- Assert.assertEquals(JavaEEQuickPeek.UNKNOWN, quickPeek.getType());
- Assert.assertEquals(JavaEEQuickPeek.UNKNOWN, quickPeek.getVersion());
- Assert.assertEquals(JavaEEQuickPeek.UNKNOWN, quickPeek.getJavaEEVersion());
- }
-
- public void testJavaEEFromArchive() throws Exception {
- List data = new ArrayList();
- data.add(new TestData("application-client12.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.J2EE_1_2_ID, J2EEVersionConstants.J2EE_1_2_ID,
- org.eclipse.jst.j2ee.client.ApplicationClient.class));
- data.add(new TestData("application-client13.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.J2EE_1_3_ID, J2EEVersionConstants.J2EE_1_3_ID,
- org.eclipse.jst.j2ee.client.ApplicationClient.class));
- data.add(new TestData("application-client14.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.J2EE_1_4_ID, J2EEVersionConstants.J2EE_1_4_ID,
- org.eclipse.jst.j2ee.client.ApplicationClient.class));
- data.add(new TestData("application-client5.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.JEE_5_0_ID, J2EEVersionConstants.JEE_5_0_ID,
- org.eclipse.jst.javaee.applicationclient.ApplicationClient.class));
-
- data.add(new TestData("application12.ear", J2EEVersionConstants.APPLICATION_TYPE, J2EEVersionConstants.J2EE_1_2_ID, J2EEVersionConstants.J2EE_1_2_ID,
- org.eclipse.jst.j2ee.application.Application.class));
- data.add(new TestData("application13.ear", J2EEVersionConstants.APPLICATION_TYPE, J2EEVersionConstants.J2EE_1_3_ID, J2EEVersionConstants.J2EE_1_3_ID,
- org.eclipse.jst.j2ee.application.Application.class));
- data.add(new TestData("application14.ear", J2EEVersionConstants.APPLICATION_TYPE, J2EEVersionConstants.J2EE_1_4_ID, J2EEVersionConstants.J2EE_1_4_ID,
- org.eclipse.jst.j2ee.application.Application.class));
- data.add(new TestData("application5.ear", J2EEVersionConstants.APPLICATION_TYPE, J2EEVersionConstants.JEE_5_0_ID, J2EEVersionConstants.JEE_5_0_ID,
- org.eclipse.jst.javaee.application.Application.class));
-
- data.add(new TestData("ejb-jar11.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_1_1_ID, J2EEVersionConstants.J2EE_1_2_ID, org.eclipse.jst.j2ee.ejb.EJBJar.class));
- data.add(new TestData("ejb-jar20.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_2_0_ID, J2EEVersionConstants.J2EE_1_3_ID, org.eclipse.jst.j2ee.ejb.EJBJar.class));
- data.add(new TestData("ejb-jar21.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_2_1_ID, J2EEVersionConstants.J2EE_1_4_ID, org.eclipse.jst.j2ee.ejb.EJBJar.class));
- data.add(new TestData("ejb-jar30.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_3_0_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.ejb.EJBJar.class));
-
- data.add(new TestData("ra10.rar", J2EEVersionConstants.CONNECTOR_TYPE, J2EEVersionConstants.JCA_1_0_ID, J2EEVersionConstants.J2EE_1_3_ID, org.eclipse.jst.j2ee.jca.Connector.class));
- data.add(new TestData("ra15.rar", J2EEVersionConstants.CONNECTOR_TYPE, J2EEVersionConstants.JCA_1_5_ID, J2EEVersionConstants.J2EE_1_4_ID, org.eclipse.jst.j2ee.jca.Connector.class));
-
- data.add(new TestData("web22.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_2_ID, J2EEVersionConstants.J2EE_1_2_ID, WebApp.class));
- data.add(new TestData("web23.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_3_ID, J2EEVersionConstants.J2EE_1_3_ID, WebApp.class));
- data.add(new TestData("web24.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_4_ID, J2EEVersionConstants.J2EE_1_4_ID, WebApp.class));
- data.add(new TestData("web25.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_5_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.web.WebApp.class));
-
- IArchive archive = null;
- for (int i = 0; i < data.size(); i++) {
- try {
- TestData testData = (TestData) data.get(i);
- String fileLocation = getDataPath(testData.fileName);
- IPath filePath = new Path(fileLocation);
- archive = JavaEEArchiveUtilities.INSTANCE.openArchive(filePath);
- JavaEEQuickPeek peek = JavaEEArchiveUtilities.INSTANCE.getJavaEEQuickPeek(archive);
- Assert.assertEquals(testData.type, peek.getType());
- Assert.assertEquals(testData.modVersion, peek.getVersion());
- Assert.assertEquals(testData.eeVersion, peek.getJavaEEVersion());
-
- Object modelObject = archive.getModelObject();
- Class clazz = modelObject.getClass();
- boolean foundInterface = false;
- for (Class anInterface : clazz.getInterfaces()) {
- if (!foundInterface) {
- foundInterface = anInterface == testData.modelObjectInterface;
- }
- }
- Assert.assertTrue("Returned Model Object: " + modelObject.getClass().getName() + " does not implement " + testData.modelObjectInterface.getName(), foundInterface);
- } finally {
- if (archive != null) {
- JavaEEArchiveUtilities.INSTANCE.closeArchive(archive);
- }
- }
- }
- }
-
- public void testJavaEE() throws Exception {
-
- List data = getXMLData();
-
- InputStream in = null;
-
- for (int i = 0; i < data.size(); i++) {
- try {
- TestData testData = (TestData) data.get(i);
- in = new FileInputStream(new File(getDataPath(testData.fileName)));
- JavaEEQuickPeek peek = new JavaEEQuickPeek(in);
- Assert.assertEquals(testData.type, peek.getType());
- Assert.assertEquals(testData.modVersion, peek.getVersion());
- Assert.assertEquals(testData.eeVersion, peek.getJavaEEVersion());
- } finally {
- if (in != null) {
- in.close();
- }
- }
- }
-
- }
-
- private List getXMLData() {
- List data = new ArrayList();
- data.add(new TestData("application-client12.xml", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.J2EE_1_2_ID, J2EEVersionConstants.J2EE_1_2_ID));
- data.add(new TestData("application-client13.xml", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.J2EE_1_3_ID, J2EEVersionConstants.J2EE_1_3_ID));
- data.add(new TestData("application-client14.xml", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.J2EE_1_4_ID, J2EEVersionConstants.J2EE_1_4_ID));
- data.add(new TestData("application-client5.xml", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.JEE_5_0_ID, J2EEVersionConstants.JEE_5_0_ID));
-
- data.add(new TestData("application12.xml", J2EEVersionConstants.APPLICATION_TYPE, J2EEVersionConstants.J2EE_1_2_ID, J2EEVersionConstants.J2EE_1_2_ID));
- data.add(new TestData("application13.xml", J2EEVersionConstants.APPLICATION_TYPE, J2EEVersionConstants.J2EE_1_3_ID, J2EEVersionConstants.J2EE_1_3_ID));
- data.add(new TestData("application14.xml", J2EEVersionConstants.APPLICATION_TYPE, J2EEVersionConstants.J2EE_1_4_ID, J2EEVersionConstants.J2EE_1_4_ID));
- data.add(new TestData("application5.xml", J2EEVersionConstants.APPLICATION_TYPE, J2EEVersionConstants.JEE_5_0_ID, J2EEVersionConstants.JEE_5_0_ID));
-
- data.add(new TestData("ejb-jar11.xml", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_1_1_ID, J2EEVersionConstants.J2EE_1_2_ID));
- data.add(new TestData("ejb-jar20.xml", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_2_0_ID, J2EEVersionConstants.J2EE_1_3_ID));
- data.add(new TestData("ejb-jar21.xml", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_2_1_ID, J2EEVersionConstants.J2EE_1_4_ID));
- data.add(new TestData("ejb-jar30.xml", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_3_0_ID, J2EEVersionConstants.JEE_5_0_ID));
-
- data.add(new TestData("ra10.xml", J2EEVersionConstants.CONNECTOR_TYPE, J2EEVersionConstants.JCA_1_0_ID, J2EEVersionConstants.J2EE_1_3_ID));
- data.add(new TestData("ra15.xml", J2EEVersionConstants.CONNECTOR_TYPE, J2EEVersionConstants.JCA_1_5_ID, J2EEVersionConstants.J2EE_1_4_ID));
-
- data.add(new TestData("web22.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_2_ID, J2EEVersionConstants.J2EE_1_2_ID));
- data.add(new TestData("web23.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_3_ID, J2EEVersionConstants.J2EE_1_3_ID));
- data.add(new TestData("web24.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_4_ID, J2EEVersionConstants.J2EE_1_4_ID));
- data.add(new TestData("web25.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_5_ID, J2EEVersionConstants.JEE_5_0_ID));
- data.add(new TestData("web30.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_3_0_ID, J2EEVersionConstants.JEE_6_0_ID));
- data.add(new TestData("web31.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_3_1_ID, J2EEVersionConstants.JEE_7_0_ID));
- data.add(new TestData("web40.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_4_0_ID, J2EEVersionConstants.JEE_8_0_ID));
-
- // Test the Web-App DDs without the schema specified
- data.add(new TestData("web24min.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_4_ID, J2EEVersionConstants.J2EE_1_4_ID));
- data.add(new TestData("web25min.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_5_ID, J2EEVersionConstants.JEE_5_0_ID));
- data.add(new TestData("web30min.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_3_0_ID, J2EEVersionConstants.JEE_6_0_ID));
- data.add(new TestData("web31min.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_3_1_ID, J2EEVersionConstants.JEE_7_0_ID));
- data.add(new TestData("web40min.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_4_0_ID, J2EEVersionConstants.JEE_8_0_ID));
-
- // test some bogus dds as well
- data.add(new TestData("notxml.xml", J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
- data.add(new TestData("notjavaee.xml", J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
-
- data.add(new TestData("application-client0.xml", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
- data.add(new TestData("application-client00.xml", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
- data.add(new TestData("application-client000.xml", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
-
- data.add(new TestData("application0.xml", J2EEVersionConstants.APPLICATION_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
- data.add(new TestData("application00.xml", J2EEVersionConstants.APPLICATION_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
- data.add(new TestData("application000.xml", J2EEVersionConstants.APPLICATION_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
-
- data.add(new TestData("ejb-jar0.xml", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
- data.add(new TestData("ejb-jar00.xml", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
- data.add(new TestData("ejb-jar000.xml", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
-
- data.add(new TestData("ra0.xml", J2EEVersionConstants.CONNECTOR_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
- data.add(new TestData("ra00.xml", J2EEVersionConstants.CONNECTOR_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
- data.add(new TestData("ra000.xml", J2EEVersionConstants.CONNECTOR_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
-
- data.add(new TestData("web0.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
- data.add(new TestData("web00.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
- data.add(new TestData("web000.xml", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.UNKNOWN, J2EEVersionConstants.UNKNOWN));
- return data;
- }
-
- public void testNormalizeSchemaLocation() throws Exception {
- verifyNormalizeSchemaLocation("", "");
- verifyNormalizeSchemaLocation("", " ");
- verifyNormalizeSchemaLocation("", " ");
- verifyNormalizeSchemaLocation("", " ");
- verifyNormalizeSchemaLocation("", "\n");
- verifyNormalizeSchemaLocation("", "\n\n");
- verifyNormalizeSchemaLocation("", "\n\n\n");
- verifyNormalizeSchemaLocation("", "\n ");
- verifyNormalizeSchemaLocation("simple", "simple");
- verifyNormalizeSchemaLocation("simple", "simple ");
- verifyNormalizeSchemaLocation("simple", "simple ");
- verifyNormalizeSchemaLocation("simple", "simple ");
- verifyNormalizeSchemaLocation("simple", " simple");
- verifyNormalizeSchemaLocation("simple", " simple ");
- verifyNormalizeSchemaLocation("simple", "simple\n");
- verifyNormalizeSchemaLocation("simple", "\nsimple\n");
- verifyNormalizeSchemaLocation("simple", "simple\r");
- verifyNormalizeSchemaLocation("simple", "simple\t");
- verifyNormalizeSchemaLocation("simple", "simple\n\n");
- verifyNormalizeSchemaLocation("simple", "simple\n\r");
- verifyNormalizeSchemaLocation("simple", "simple\n\t");
- verifyNormalizeSchemaLocation("simple", "simple \n");
- verifyNormalizeSchemaLocation("simple", "simple\r ");
- verifyNormalizeSchemaLocation("simple", " \t\tsimple\t");
- verifyNormalizeSchemaLocation("simple", "simple\n \n");
- verifyNormalizeSchemaLocation("simple", "\r \rsimple \n\r");
- verifyNormalizeSchemaLocation("simple", " simple\n\t");
-
- verifyNormalizeSchemaLocation("simple simple", "simple simple");
- verifyNormalizeSchemaLocation("simple simple", "simple simple");
- verifyNormalizeSchemaLocation("simple simple", "simple\nsimple");
- verifyNormalizeSchemaLocation("simple simple", "simple\rsimple");
- verifyNormalizeSchemaLocation("simple simple", "simple\tsimple");
- verifyNormalizeSchemaLocation("simple simple", "simple \nsimple");
- verifyNormalizeSchemaLocation("simple simple", "simple\r simple");
- verifyNormalizeSchemaLocation("simple simple", "simple \t simple");
- verifyNormalizeSchemaLocation("simple simple", "simple simple ");
- verifyNormalizeSchemaLocation("simple simple", " simple simple");
- verifyNormalizeSchemaLocation("simple simple", " simple simple ");
- verifyNormalizeSchemaLocation("simple simple", "simple\n simple\n");
- verifyNormalizeSchemaLocation("simple simple", "simple\r simple\r");
- verifyNormalizeSchemaLocation("simple simple", "simple\t simple\t");
- verifyNormalizeSchemaLocation("simple simple", "simple\n\nsimple");
- verifyNormalizeSchemaLocation("simple simple", "simple\n\rsimple\n\n");
- verifyNormalizeSchemaLocation("simple simple", "simple\n\tsimple\n\t");
- verifyNormalizeSchemaLocation("simple simple", "simple \nsimple \n");
- verifyNormalizeSchemaLocation("simple simple", "simple\r simple\r ");
- verifyNormalizeSchemaLocation("simple simple", " \t\tsimple\t \t\tsimple\t");
- verifyNormalizeSchemaLocation("simple simple", "simple\n \nsimple\n \n");
- verifyNormalizeSchemaLocation("simple simple", "\r \rsimple \n\r\r \rsimple \n\r");
- verifyNormalizeSchemaLocation("simple simple", " simple\n\t simple\n\t");
- }
-
- private String verifyNormalizeSchemaLocation(String normalizedSchemaLocation, String someSchemaLocation) {
- String normalizedString = JavaEEQuickPeek.normalizeSchemaLocation(someSchemaLocation);
- if(!normalizedSchemaLocation.equals(normalizedString)){
- Assert.assertEquals(normalizedSchemaLocation, normalizedString);
- }
- return normalizedString;
- }
-
- public void testEAR50Import_NoDD() throws Exception {
- List nestedArchiveData = new ArrayList();
- nestedArchiveData.add(new TestData("application-client12.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.J2EE_1_2_ID, J2EEVersionConstants.J2EE_1_2_ID,
- org.eclipse.jst.j2ee.client.ApplicationClient.class));
- nestedArchiveData.add(new TestData("application-client13.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.J2EE_1_3_ID, J2EEVersionConstants.J2EE_1_3_ID,
- org.eclipse.jst.j2ee.client.ApplicationClient.class));
- nestedArchiveData.add(new TestData("application-client14.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.J2EE_1_4_ID, J2EEVersionConstants.J2EE_1_4_ID,
- org.eclipse.jst.j2ee.client.ApplicationClient.class));
- nestedArchiveData.add(new TestData("AppClient5_NoDD.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.JEE_5_0_ID, J2EEVersionConstants.JEE_5_0_ID,
- org.eclipse.jst.javaee.applicationclient.ApplicationClient.class));
- nestedArchiveData.add(new TestData("AppClient5_WithDD.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.JEE_5_0_ID, J2EEVersionConstants.JEE_5_0_ID,
- org.eclipse.jst.javaee.applicationclient.ApplicationClient.class));
-
- nestedArchiveData.add(new TestData("ejb-jar11.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_1_1_ID, J2EEVersionConstants.J2EE_1_2_ID, org.eclipse.jst.j2ee.ejb.EJBJar.class));
- nestedArchiveData.add(new TestData("ejb-jar20.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_2_0_ID, J2EEVersionConstants.J2EE_1_3_ID, org.eclipse.jst.j2ee.ejb.EJBJar.class));
- nestedArchiveData.add(new TestData("ejb-jar21.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_2_1_ID, J2EEVersionConstants.J2EE_1_4_ID, org.eclipse.jst.j2ee.ejb.EJBJar.class));
- nestedArchiveData.add(new TestData("EJB3_NoDD_MessageDriven.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_3_0_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.ejb.EJBJar.class));
- nestedArchiveData.add(new TestData("EJB3_NoDD_Stateful.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_3_0_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.ejb.EJBJar.class));
- nestedArchiveData.add(new TestData("EJB3_NoDD_Stateless.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_3_0_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.ejb.EJBJar.class));
- nestedArchiveData.add(new TestData("EJB3_WithDD.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_3_0_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.ejb.EJBJar.class));
-
- nestedArchiveData.add(new TestData("ra10.rar", J2EEVersionConstants.CONNECTOR_TYPE, J2EEVersionConstants.JCA_1_0_ID, J2EEVersionConstants.J2EE_1_3_ID, org.eclipse.jst.j2ee.jca.Connector.class));
- nestedArchiveData.add(new TestData("ra15.rar", J2EEVersionConstants.CONNECTOR_TYPE, J2EEVersionConstants.JCA_1_5_ID, J2EEVersionConstants.J2EE_1_4_ID, org.eclipse.jst.j2ee.jca.Connector.class));
-
- nestedArchiveData.add(new TestData("web22.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_2_ID, J2EEVersionConstants.J2EE_1_2_ID, WebApp.class));
- nestedArchiveData.add(new TestData("web23.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_3_ID, J2EEVersionConstants.J2EE_1_3_ID, WebApp.class));
- nestedArchiveData.add(new TestData("web24.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_4_ID, J2EEVersionConstants.J2EE_1_4_ID, WebApp.class));
- nestedArchiveData.add(new TestData("Web25_NoDD.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_5_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.web.WebApp.class));
- nestedArchiveData.add(new TestData("Web25_WithDD.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_5_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.web.WebApp.class));
-
- TestData earData = new TestData("EAR5_NoDD.ear", J2EEVersionConstants.APPLICATION_TYPE, J2EEVersionConstants.JEE_5_0_ID, J2EEVersionConstants.JEE_5_0_ID,
- org.eclipse.jst.javaee.application.Application.class,false);
- runEAR50Tests(earData, nestedArchiveData);
- }
-
- public void testEAR50Import_WithDD() throws Exception {
- List nestedArchiveData = new ArrayList();
- nestedArchiveData.add(new TestData("application-client12.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.J2EE_1_2_ID, J2EEVersionConstants.J2EE_1_2_ID,
- org.eclipse.jst.j2ee.client.ApplicationClient.class));
- nestedArchiveData.add(new TestData("application-client13.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.J2EE_1_3_ID, J2EEVersionConstants.J2EE_1_3_ID,
- org.eclipse.jst.j2ee.client.ApplicationClient.class));
- nestedArchiveData.add(new TestData("application-client14.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.J2EE_1_4_ID, J2EEVersionConstants.J2EE_1_4_ID,
- org.eclipse.jst.j2ee.client.ApplicationClient.class));
- nestedArchiveData.add(new TestData("AppClient5_NoDD.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.JEE_5_0_ID, J2EEVersionConstants.JEE_5_0_ID,
- org.eclipse.jst.javaee.applicationclient.ApplicationClient.class));
- nestedArchiveData.add(new TestData("AppClient5_WithDD.jar", J2EEVersionConstants.APPLICATION_CLIENT_TYPE, J2EEVersionConstants.JEE_5_0_ID, J2EEVersionConstants.JEE_5_0_ID,
- org.eclipse.jst.javaee.applicationclient.ApplicationClient.class));
-
- nestedArchiveData.add(new TestData("ejb-jar11.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_1_1_ID, J2EEVersionConstants.J2EE_1_2_ID, org.eclipse.jst.j2ee.ejb.EJBJar.class));
- nestedArchiveData.add(new TestData("ejb-jar20.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_2_0_ID, J2EEVersionConstants.J2EE_1_3_ID, org.eclipse.jst.j2ee.ejb.EJBJar.class));
- nestedArchiveData.add(new TestData("ejb-jar21.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_2_1_ID, J2EEVersionConstants.J2EE_1_4_ID, org.eclipse.jst.j2ee.ejb.EJBJar.class));
- nestedArchiveData.add(new TestData("EJB3_NoDD_MessageDriven.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_3_0_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.ejb.EJBJar.class));
- nestedArchiveData.add(new TestData("EJB3_NoDD_Stateful.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_3_0_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.ejb.EJBJar.class));
- nestedArchiveData.add(new TestData("EJB3_NoDD_Stateless.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_3_0_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.ejb.EJBJar.class));
- nestedArchiveData.add(new TestData("EJB3_WithDD.jar", J2EEVersionConstants.EJB_TYPE, J2EEVersionConstants.EJB_3_0_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.ejb.EJBJar.class));
-
- nestedArchiveData.add(new TestData("ra10.rar", J2EEVersionConstants.CONNECTOR_TYPE, J2EEVersionConstants.JCA_1_0_ID, J2EEVersionConstants.J2EE_1_3_ID, org.eclipse.jst.j2ee.jca.Connector.class));
- nestedArchiveData.add(new TestData("ra15.rar", J2EEVersionConstants.CONNECTOR_TYPE, J2EEVersionConstants.JCA_1_5_ID, J2EEVersionConstants.J2EE_1_4_ID, org.eclipse.jst.j2ee.jca.Connector.class));
-
- nestedArchiveData.add(new TestData("web22.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_2_ID, J2EEVersionConstants.J2EE_1_2_ID, WebApp.class));
- nestedArchiveData.add(new TestData("web23.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_3_ID, J2EEVersionConstants.J2EE_1_3_ID, WebApp.class));
- nestedArchiveData.add(new TestData("web24.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_4_ID, J2EEVersionConstants.J2EE_1_4_ID, WebApp.class));
- nestedArchiveData.add(new TestData("Web25_NoDD.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_5_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.web.WebApp.class));
- nestedArchiveData.add(new TestData("Web25_WithDD.war", J2EEVersionConstants.WEB_TYPE, J2EEVersionConstants.WEB_2_5_ID, J2EEVersionConstants.JEE_5_0_ID, org.eclipse.jst.javaee.web.WebApp.class));
-
- TestData earData = new TestData("EAR5_WithDD.ear", J2EEVersionConstants.APPLICATION_TYPE, J2EEVersionConstants.JEE_5_0_ID, J2EEVersionConstants.JEE_5_0_ID,
- org.eclipse.jst.javaee.application.Application.class,true);
- runEAR50Tests(earData, nestedArchiveData);
- }
-
- private void runEAR50Tests(TestData earData, List<TestData> nestedArchiveData) throws Exception {
- IArchive earArchive = null;
-
- try {
- String earLocation = getDataPath(earData.fileName);
- IPath earPath = new Path(earLocation);
- earArchive = JavaEEArchiveUtilities.INSTANCE.openArchive(earPath);
- earArchive.getArchiveOptions().setOption(JavaEEArchiveUtilities.DISCRIMINATE_EJB_ANNOTATIONS, Boolean.TRUE);
- JavaEEQuickPeek peek = JavaEEArchiveUtilities.INSTANCE.getJavaEEQuickPeek(earArchive);
- Assert.assertEquals(earData.fileName + " type", earData.type, peek.getType());
- if (earData.deploymentDescriptor){
- Assert.assertEquals(earData.fileName + " mod version", earData.modVersion, peek.getVersion());
- Assert.assertEquals(earData.fileName + " ee version", earData.eeVersion, peek.getJavaEEVersion());
- }
- else{
- Assert.assertTrue(earData.fileName + " mod version", peek.getVersion() >= earData.modVersion);
- Assert.assertTrue(earData.fileName + " ee version", peek.getJavaEEVersion() >= earData.eeVersion);
- }
- IArchiveResource innerArchiveResource;
- IArchive innerArchive = null;
- for(TestData testData : nestedArchiveData) {
- innerArchiveResource = earArchive.getArchiveResource(new Path(testData.fileName));
- innerArchive = earArchive.getNestedArchive(innerArchiveResource);
- peek = JavaEEArchiveUtilities.INSTANCE.getJavaEEQuickPeek(innerArchive);
- AssertWarn.warnEquals(testData.fileName + " type", testData.type, peek.getType());
- AssertWarn.warnEquals(testData.fileName + " mod version", testData.modVersion, peek.getVersion());
- AssertWarn.warnEquals(testData.fileName + " ee version", testData.eeVersion, peek.getJavaEEVersion());
-
- //TODO uncomment this block when this bug is resolved: https://bugs.eclipse.org/bugs/show_bug.cgi?id=199953
- System.err.println("TODO -- can't getModelObject from inner archive of JEE5 EAR");
- System.err.println(" -- see https://bugs.eclipse.org/bugs/show_bug.cgi?id=199953");
-// Object modelObject = innerArchive.getModelObject();
-// Class clazz = modelObject.getClass();
-// boolean foundInterface = false;
-// for (Class anInterface : clazz.getInterfaces()) {
-// if (!foundInterface) {
-// foundInterface = anInterface == testData.modelObjectInterface;
-// }
-// }
-// Assert.assertTrue("Returned Model Object: " + modelObject.getClass().getName() + " does not implement " + testData.modelObjectInterface.getName(), foundInterface);
- }
-
- } finally {
- if(earArchive != null) {
- JavaEEArchiveUtilities.INSTANCE.closeArchive(earArchive);
- }
- }
- }
-}