Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable Jakarta EE9 features #402

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<String> enables = new HashSet<String>(8);
private final Set<String> apiJars = new HashSet<String>(8);
private final Set<String> spiJars = new HashSet<String>(8);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ protected ProcessBuilder createProcessBuilder(Map<String, Object> 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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ private static ArrayList<Class<? extends TestCase>> addTestCases() {
testsuites.add(AlternativeFeatureTest.class);
testsuites.add(MixedFeatureTest.class);
testsuites.add(ImportFeatureTest.class);
testsuites.add(JakartaEE9FeatureTest.class);
}
return testsuites;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<factorypath>
<factorypathentry kind="PLUGIN" id="com.ibm.jee.annotations.processor" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="PLUGIN" id="com.ibm.etools.javaee.cdi.ext.ui" enabled="false" runInBatchMode="false"/>
<factorypathentry kind="PLUGIN" id="com.ibm.jaxrs.annotations.processor" enabled="false" runInBatchMode="false"/>
</factorypath>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>JSP</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Class-Path:

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
Hello from test.jsp
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!--
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
-->
<server description="new server">

<!-- Enable features -->
<featureManager>
<feature>localConnector-1.0</feature>
<feature>servlet-4.0</feature>
</featureManager>

<!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
<httpEndpoint httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint"/>

</server>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!--
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
-->
<server>

<!-- Enable features -->
<featureManager>
<feature>localConnector-1.0</feature>
<feature>servlet-4.0</feature>
<feature>jsp-3.0</feature>
</featureManager>

<httpEndpoint host="localhost" httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint">
</httpEndpoint>

</server>