forked from OpenLiberty/ci.gradle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test case for versionless features
- Loading branch information
1 parent
b6ad004
commit fbd54fc
Showing
9 changed files
with
204 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
src/test/groovy/io/openliberty/tools/gradle/KernelInstallVersionlessFeatureTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* (C) Copyright IBM Corporation 2024. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.openliberty.tools.gradle | ||
|
||
import static junit.framework.Assert.assertEquals | ||
import static org.junit.Assert.* | ||
|
||
import org.junit.Before | ||
import org.junit.BeforeClass | ||
import org.junit.Test | ||
|
||
import io.openliberty.tools.common.plugins.util.InstallFeatureUtil | ||
|
||
class KernelInstallVersionlessFeatureTest extends AbstractIntegrationTest{ | ||
static File resourceDir = new File("build/resources/test/kernel-install-versionless-feature-test") | ||
static File buildDir = new File(integTestDir, "/kernel-install-versionless-feature-test") | ||
static String buildFilename = "build.gradle" | ||
|
||
@BeforeClass | ||
public static void setup() { | ||
createDir(buildDir) | ||
createTestProject(buildDir, resourceDir, buildFilename) | ||
} | ||
|
||
@Before | ||
public void before() { | ||
runTasks(buildDir, "libertyCreate") | ||
copyServer("server_empty.xml") | ||
deleteDir(new File(buildDir, "build/wlp/lib/features")) | ||
} | ||
|
||
@Test | ||
/** | ||
* Install with only server.xml features | ||
*/ | ||
public void testInstallVersionlessFeaturesServer() { | ||
copyBuildFiles(new File(resourceDir, "install_features_server.gradle"), buildDir) | ||
runTasks(buildDir, "libertyCreate") | ||
copyServer("server_versionless_feature.xml") | ||
runTasks(buildDir, "installFeature") | ||
assertInstalled("beanValidation-2.0") | ||
assertInstalled("servlet-4.0") | ||
assertInstalled("jpa-2.2") | ||
assertInstalled("ejb-3.2") | ||
assertNotInstalled("couchdb-1.0") | ||
assertNotInstalled("distributedMap-1.0") | ||
} | ||
|
||
private copyServer(String serverFile) { | ||
copyFile(new File(resourceDir, serverFile), new File(buildDir, "build/wlp/usr/servers/defaultServer/server.xml")) | ||
} | ||
|
||
private void assertInstallStatus(String feature, boolean expectation) throws Exception { | ||
String expectationString = (expectation ? "installed" : "not installed"); | ||
assertEquals("Feature " + feature + " was expected to be " + expectationString + " in the lib/features directory", expectation, existsInFeaturesDirectory(feature)); | ||
String featureInfo = getFeatureInfo(); | ||
assertEquals("Feature " + feature + " was expected to be " + expectationString + " according to productInfo featureInfo: " + featureInfo, expectation, featureInfo.contains(feature)); | ||
} | ||
|
||
protected void assertInstalled(String feature) throws Exception { | ||
assertInstallStatus(feature, true); | ||
} | ||
|
||
protected void assertNotInstalled(String feature) throws Exception { | ||
assertInstallStatus(feature, false); | ||
} | ||
|
||
private boolean existsInFeaturesDirectory(String feature) { | ||
File[] features; | ||
File featuresDir = new File(buildDir, "build/wlp/lib/features") | ||
|
||
features = featuresDir.listFiles(new FilenameFilter() { | ||
public boolean accept(File dir, String name) { | ||
return name.toLowerCase().equals("com.ibm.websphere.appserver." + feature.toLowerCase() + ".mf"); | ||
} | ||
}); | ||
|
||
return features.size() >= 1; | ||
} | ||
|
||
private String getFeatureInfo() throws Exception { | ||
File installDirectory = new File(buildDir, "build/wlp") | ||
return InstallFeatureUtil.productInfo(installDirectory, "featureInfo"); | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
src/test/resources/kernel-install-feature-test/server_versionless_feature.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<server description="default server"> | ||
<featureManager> | ||
<feature>beanValidation</feature> | ||
<feature>servlet</feature> | ||
<feature>jpa</feature> | ||
<feature>ejb</feature> | ||
<platform>javaee-8.0</platform> | ||
</featureManager> | ||
</server> |
24 changes: 24 additions & 0 deletions
24
src/test/resources/kernel-install-versionless-feature-test/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apply plugin: 'liberty' | ||
|
||
buildscript { | ||
repositories{ | ||
mavenLocal() | ||
mavenCentral() | ||
maven { | ||
name = 'Sonatype Nexus Snapshots' | ||
url = 'https://oss.sonatype.org/content/repositories/snapshots/' | ||
} | ||
} | ||
dependencies { | ||
classpath "io.openliberty.tools:liberty-gradle-plugin:$lgpVersion" | ||
} | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
liberty { | ||
runtime = ['group': runtimeGroup,'name':kernelArtifactId,'version':runtimeVersion] | ||
} |
24 changes: 24 additions & 0 deletions
24
src/test/resources/kernel-install-versionless-feature-test/build_wlp.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apply plugin: 'liberty' | ||
|
||
buildscript { | ||
repositories{ | ||
mavenLocal() | ||
mavenCentral() | ||
maven { | ||
name = 'Sonatype Nexus Snapshots' | ||
url = 'https://oss.sonatype.org/content/repositories/snapshots/' | ||
} | ||
} | ||
dependencies { | ||
classpath "io.openliberty.tools:liberty-gradle-plugin:$lgpVersion" | ||
} | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
libertyRuntime group: 'com.ibm.websphere.appserver.runtime', name: 'wlp-kernel', version: runtimeVersion | ||
} |
31 changes: 31 additions & 0 deletions
31
src/test/resources/kernel-install-versionless-feature-test/install_features_server.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
buildscript { | ||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
maven { | ||
name = 'Sonatype Nexus Snapshots' | ||
url = 'https://oss.sonatype.org/content/repositories/snapshots/' | ||
} | ||
} | ||
dependencies { | ||
classpath "io.openliberty.tools:liberty-gradle-plugin:$lgpVersion" | ||
} | ||
} | ||
|
||
apply plugin: 'liberty' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
libertyRuntime group: runtimeGroup, name: kernelArtifactId, version: runtimeVersion | ||
} | ||
|
||
liberty { | ||
server{ | ||
features { | ||
acceptLicense = true | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/test/resources/kernel-install-versionless-feature-test/server_empty.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<server description="default server"> | ||
<featureManager> | ||
|
||
</featureManager> | ||
</server> |
9 changes: 9 additions & 0 deletions
9
src/test/resources/kernel-install-versionless-feature-test/server_versionless_feature.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<server description="default server"> | ||
<featureManager> | ||
<feature>beanValidation</feature> | ||
<feature>servlet</feature> | ||
<feature>jpa</feature> | ||
<feature>ejb</feature> | ||
<platform>javaee-8.0</platform> | ||
</featureManager> | ||
</server> |
1 change: 1 addition & 0 deletions
1
src/test/resources/kernel-install-versionless-feature-test/settings.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
//Empty |