diff --git a/dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/generation/Feature.java b/dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/generation/Feature.java index 4904d105..f18d299c 100644 --- a/dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/generation/Feature.java +++ b/dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/generation/Feature.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Corporation - initial API and implementation + * IBM Corporation - initial API and implementation *******************************************************************************/ package com.ibm.ws.st.core.internal.generation; @@ -30,6 +30,9 @@ public class Feature implements Cloneable { private final FeatureType featureType; + private static final String JAKARTA_EE9_FEATURE_DIRECT_DEPENDENCY = "com.ibm.websphere.appserver.eeCompatible-9.0"; + private static final String JAKARTA_EE9_CONVENIENCE_FEATURE_NAME = "jakartaee-9.0"; + private final Set enables = new HashSet(8); private final Set apiJars = new HashSet(8); private final Set spiJars = new HashSet(8); @@ -76,9 +79,9 @@ public String getDisplayName() { * @return the process type */ public ProcessType getProcessType() { - if(processTypes.size() == 1 && processTypes.contains("CLIENT")) - return ProcessType.CLIENT; - + if (processTypes.size() == 1 && processTypes.contains("CLIENT")) + return ProcessType.CLIENT; + return ProcessType.SERVER; } @@ -187,11 +190,23 @@ public String getFeatureInfoName() { return featureInfoName; } + /** + * @return if the feature is Jakarta EE9 feature + */ + public boolean isJakartaEE9Feature() { + if (includes.containsKey(JAKARTA_EE9_FEATURE_DIRECT_DEPENDENCY) + || name.equals(JAKARTA_EE9_CONVENIENCE_FEATURE_NAME)) { + return true; + } + + return false; + } + /** * A feature can be a public feature and still have auto provisions * making it an auto feature as well so a separate method is needed * since checking the type is not sufficient. - * + * * @return If this feature is an auto feature */ public boolean isAutoFeature() { diff --git a/dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/generation/FeatureInfoHandler.java b/dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/generation/FeatureInfoHandler.java index 66e417c9..d3a5e35b 100644 --- a/dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/generation/FeatureInfoHandler.java +++ b/dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/generation/FeatureInfoHandler.java @@ -198,8 +198,8 @@ public void endElement(String uri, String localName, String qname) { } chars = null; } else if (qname.equals(FEATURE)) { - //don't add the client only features to the map. For Client only features, processType is set to CLIENT - if (!current.getProcessType().equals(ProcessType.CLIENT)) { + // Don't add the client only features and Jakarta EE9 features to the map. For Client only features, processType is set to CLIENT + if (!current.getProcessType().equals(ProcessType.CLIENT) && !current.isJakartaEE9Feature()) { featureMaps.get(FeatureMapType.PUBLIC_FEATURES_KEYED_BY_NAME).put(current.getName(), current); // Older feature lists may not have a symbolic name if (current.getSymbolicName() != null) { diff --git a/dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/repository/FeatureInstaller.java b/dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/repository/FeatureInstaller.java index 8b848790..f535beec 100644 --- a/dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/repository/FeatureInstaller.java +++ b/dev/com.ibm.ws.st.core/src/com/ibm/ws/st/core/internal/repository/FeatureInstaller.java @@ -277,7 +277,7 @@ protected ProcessBuilder createProcessBuilder(Map settings, bool jvmArgs += " -D" + REPOSITORIES_LOCATION_OVERRIDE_PROP_NAME + "=" + repoPropsURL; } - if (jvmArgs != null && jvmArgs.length() > 0) { + if (jvmArgs.length() > 0) { env.put("JVM_ARGS", jvmArgs); } } diff --git a/dev/com.ibm.ws.st.core_tests/bvt/src/com/ibm/ws/st/core/tests/jee/featureDetection/AllFeatureTests.java b/dev/com.ibm.ws.st.core_tests/bvt/src/com/ibm/ws/st/core/tests/jee/featureDetection/AllFeatureTests.java index 66621424..39d17c91 100644 --- a/dev/com.ibm.ws.st.core_tests/bvt/src/com/ibm/ws/st/core/tests/jee/featureDetection/AllFeatureTests.java +++ b/dev/com.ibm.ws.st.core_tests/bvt/src/com/ibm/ws/st/core/tests/jee/featureDetection/AllFeatureTests.java @@ -39,6 +39,7 @@ private static ArrayList> addTestCases() { testsuites.add(AlternativeFeatureTest.class); testsuites.add(MixedFeatureTest.class); testsuites.add(ImportFeatureTest.class); + testsuites.add(JakartaEE9FeatureTest.class); } return testsuites; } diff --git a/dev/com.ibm.ws.st.core_tests/bvt/src/com/ibm/ws/st/core/tests/jee/featureDetection/JakartaEE9FeatureTest.java b/dev/com.ibm.ws.st.core_tests/bvt/src/com/ibm/ws/st/core/tests/jee/featureDetection/JakartaEE9FeatureTest.java new file mode 100644 index 00000000..a490519e --- /dev/null +++ b/dev/com.ibm.ws.st.core_tests/bvt/src/com/ibm/ws/st/core/tests/jee/featureDetection/JakartaEE9FeatureTest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2020 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 com.ibm.ws.st.core.tests.jee.featureDetection; + +import org.eclipse.core.runtime.Path; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +import com.ibm.ws.st.core.tests.util.WLPCommonUtil; +import com.ibm.ws.st.tests.common.util.TestCaseDescriptor; + +/** + * Test if Jakarta EE9 features are added automatically when an app is added to the server. + * + * Expected results: given we decide to disable all Jakarta EE9 features, + * so Jakarta EE9 features shouldn't be added automatically. + */ +@TestCaseDescriptor(description = "Check required feature detection for Jakarta EE9 features", isStable = true) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class JakartaEE9FeatureTest extends BaseFeatureTest { + private static final String TEST_NAME = JakartaEE9FeatureTest.class.getSimpleName(); + private static final Path RESOURCE_PATH = new Path("FeatureTesting/" + TEST_NAME); + private static final String SERVER_NAME = "JakartaEE9FeatureTestServer"; + private static final String JSP_PROJECT = "JSP"; + + private static final String[] ALL_PROJECTS = { JSP_PROJECT }; + + @Test + public void test01_doSetup() throws Exception { + print("Starting test: " + TEST_NAME); + init(); + createRuntime(); + createServer(runtime, SERVER_NAME, "resources/" + RESOURCE_PATH + "/" + SERVER_NAME); + createVM(JDK_NAME); + importProjects(RESOURCE_PATH, ALL_PROJECTS); + startServer(); + } + + @Test + public void test02_testJSP() throws Exception { + try { + addApp(JSP_PROJECT); + checkFeatures("jsp-2.3"); + testPingWebPage("JSP/test.jsp", "Hello from test.jsp"); + } finally { + cleanupAfterTest(JSP_PROJECT); + } + } + + @Test + public void test99_doTearDown() throws Exception { + stopServer(); + WLPCommonUtil.cleanUp(); + wait("Ending test: " + TEST_NAME + "\n", 1000); + } +} diff --git a/dev/com.ibm.ws.st.core_tests/bvt/src/com/ibm/ws/st/core/tests/validation/FeatureValidationTest.java b/dev/com.ibm.ws.st.core_tests/bvt/src/com/ibm/ws/st/core/tests/validation/FeatureValidationTest.java index 24fa1c96..d3ae2805 100644 --- a/dev/com.ibm.ws.st.core_tests/bvt/src/com/ibm/ws/st/core/tests/validation/FeatureValidationTest.java +++ b/dev/com.ibm.ws.st.core_tests/bvt/src/com/ibm/ws/st/core/tests/validation/FeatureValidationTest.java @@ -103,6 +103,20 @@ public void test6_unrecognizedFeature() throws Exception { deleteRuntimeServer(serverName); } + @Test + public void test7_jakartaEE9Feature() throws Exception { + // Test that there is an warning message if a feature + // is Jakarta EE9 feature. + String serverName = "jakartaEE9Feature"; + setupRuntimeServer(RESOURCE_PATH, serverName); + IFile file = getServerFile(serverName, "server.xml"); + ValidatorMessage[] messages = TestUtil.validate(file); + checkMessageCount(messages, 1); + checkMessage(messages[0], NLS.bind(Messages.unrecognizedFeature, "jsp-3.0"), + serverName + "/" + file.getName(), 17); + deleteRuntimeServer(serverName); + } + @Test public void test99_doTearDown() { cleanUp(); diff --git a/dev/com.ibm.ws.st.core_tests/resources/FeatureTesting/JakartaEE9FeatureTest/JSP/.apt_generated/.gitkeep b/dev/com.ibm.ws.st.core_tests/resources/FeatureTesting/JakartaEE9FeatureTest/JSP/.apt_generated/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/dev/com.ibm.ws.st.core_tests/resources/FeatureTesting/JakartaEE9FeatureTest/JSP/.factorypath b/dev/com.ibm.ws.st.core_tests/resources/FeatureTesting/JakartaEE9FeatureTest/JSP/.factorypath new file mode 100644 index 00000000..a9427a51 --- /dev/null +++ b/dev/com.ibm.ws.st.core_tests/resources/FeatureTesting/JakartaEE9FeatureTest/JSP/.factorypath @@ -0,0 +1,5 @@ + + + + + diff --git a/dev/com.ibm.ws.st.core_tests/resources/FeatureTesting/JakartaEE9FeatureTest/JSP/.project b/dev/com.ibm.ws.st.core_tests/resources/FeatureTesting/JakartaEE9FeatureTest/JSP/.project new file mode 100644 index 00000000..015fb9b6 --- /dev/null +++ b/dev/com.ibm.ws.st.core_tests/resources/FeatureTesting/JakartaEE9FeatureTest/JSP/.project @@ -0,0 +1,36 @@ + + + JSP + + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.jdt.core.javanature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/dev/com.ibm.ws.st.core_tests/resources/FeatureTesting/JakartaEE9FeatureTest/JSP/WebContent/META-INF/MANIFEST.MF b/dev/com.ibm.ws.st.core_tests/resources/FeatureTesting/JakartaEE9FeatureTest/JSP/WebContent/META-INF/MANIFEST.MF new file mode 100644 index 00000000..254272e1 --- /dev/null +++ b/dev/com.ibm.ws.st.core_tests/resources/FeatureTesting/JakartaEE9FeatureTest/JSP/WebContent/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/dev/com.ibm.ws.st.core_tests/resources/FeatureTesting/JakartaEE9FeatureTest/JSP/WebContent/WEB-INF/classes/.gitkeep b/dev/com.ibm.ws.st.core_tests/resources/FeatureTesting/JakartaEE9FeatureTest/JSP/WebContent/WEB-INF/classes/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/dev/com.ibm.ws.st.core_tests/resources/FeatureTesting/JakartaEE9FeatureTest/JSP/WebContent/WEB-INF/lib/.gitkeep b/dev/com.ibm.ws.st.core_tests/resources/FeatureTesting/JakartaEE9FeatureTest/JSP/WebContent/WEB-INF/lib/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/dev/com.ibm.ws.st.core_tests/resources/FeatureTesting/JakartaEE9FeatureTest/JSP/WebContent/test.jsp b/dev/com.ibm.ws.st.core_tests/resources/FeatureTesting/JakartaEE9FeatureTest/JSP/WebContent/test.jsp new file mode 100644 index 00000000..9a9b7686 --- /dev/null +++ b/dev/com.ibm.ws.st.core_tests/resources/FeatureTesting/JakartaEE9FeatureTest/JSP/WebContent/test.jsp @@ -0,0 +1,12 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + + + +Insert title here + + +Hello from test.jsp + + \ No newline at end of file diff --git a/dev/com.ibm.ws.st.core_tests/resources/FeatureTesting/JakartaEE9FeatureTest/JSP/src/.gitkeep b/dev/com.ibm.ws.st.core_tests/resources/FeatureTesting/JakartaEE9FeatureTest/JSP/src/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/dev/com.ibm.ws.st.core_tests/resources/FeatureTesting/JakartaEE9FeatureTest/JakartaEE9FeatureTestServer/server.xml b/dev/com.ibm.ws.st.core_tests/resources/FeatureTesting/JakartaEE9FeatureTest/JakartaEE9FeatureTestServer/server.xml new file mode 100644 index 00000000..37e3718e --- /dev/null +++ b/dev/com.ibm.ws.st.core_tests/resources/FeatureTesting/JakartaEE9FeatureTest/JakartaEE9FeatureTestServer/server.xml @@ -0,0 +1,22 @@ + + + + + + localConnector-1.0 + servlet-4.0 + + + + + + \ No newline at end of file diff --git a/dev/com.ibm.ws.st.core_tests/resources/validation/jakartaEE9Feature/server.xml b/dev/com.ibm.ws.st.core_tests/resources/validation/jakartaEE9Feature/server.xml new file mode 100644 index 00000000..d819f261 --- /dev/null +++ b/dev/com.ibm.ws.st.core_tests/resources/validation/jakartaEE9Feature/server.xml @@ -0,0 +1,23 @@ + + + + + + localConnector-1.0 + servlet-4.0 + jsp-3.0 + + + + + +