mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-03-03 15:02:35 +02:00
Merge pull request #143 from alejandraferreirovidal/compatibilityCode
compatibility code for new feature
This commit is contained in:
commit
3c59ac4454
@ -33,12 +33,18 @@ class JavaArchiveDescriptor implements Serializable {
|
||||
if (EnvironmentUtils.isEnvironmentVariable(script, environmentKey)) {
|
||||
javaArchiveFile = EnvironmentUtils.getEnvironmentVariable(script, environmentKey)
|
||||
if (log) script.echo "$name file '$javaArchiveFile' retrieved from environment."
|
||||
if (!isJavaArchiveFile(javaArchiveFile)) script.error "The value '$javaArchiveFile' of the environment variable '$environmentKey' has an unexpected format."
|
||||
if (!isJavaArchiveFile(javaArchiveFile)) {
|
||||
//script.error "The value '$javaArchiveFile' of the environment variable '$environmentKey' has an unexpected format."
|
||||
javaArchiveFile += '/mta.jar' // Compatibility code
|
||||
}
|
||||
}
|
||||
else if (configuration.containsKey(stepConfigurationKey)) {
|
||||
javaArchiveFile = configuration.get(stepConfigurationKey)
|
||||
if (log) script.echo "$name file '$javaArchiveFile' retrieved from configuration."
|
||||
if (!isJavaArchiveFile(javaArchiveFile)) script.error "The value '$javaArchiveFile' of the configuration key '$stepConfigurationKey' has an unexpected format."
|
||||
if (!isJavaArchiveFile(javaArchiveFile)) {
|
||||
//script.error "The value '$javaArchiveFile' of the configuration key '$stepConfigurationKey' has an unexpected format."
|
||||
javaArchiveFile += '/mta.jar' // Compatibility code
|
||||
}
|
||||
} else {
|
||||
throw new AbortException(getMessage())
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.sap.piper.tools
|
||||
|
||||
import org.junit.Ignore
|
||||
import org.junit.BeforeClass
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
@ -75,6 +76,30 @@ class JavaArchiveDescriptorTest extends BasePipelineTest {
|
||||
assert jlr.log.contains("SAP Multitarget Application Archive Builder file '/config/mta/mta.jar' retrieved from configuration.")
|
||||
}
|
||||
|
||||
// Compatibility tests
|
||||
@Test
|
||||
void getJavaArchiveFileFromEnvironment_CompatibilityTest() {
|
||||
|
||||
helper.registerAllowedMethod('sh', [Map], { Map m -> getEnvVarsWithCompatibility(m) })
|
||||
|
||||
def javaArchiveFile = javaArchive.getFile(script, configuration)
|
||||
|
||||
assert javaArchiveFile == '/env/mta/mta.jar'
|
||||
assert jlr.log.contains("SAP Multitarget Application Archive Builder file '/env/mta' retrieved from environment.")
|
||||
}
|
||||
|
||||
@Test
|
||||
void getJavaArchiveFileFromConfiguration_CompatibilityTest() {
|
||||
|
||||
configuration = [mtaJarLocation: '/config/mta']
|
||||
|
||||
def javaArchiveFile = javaArchive.getFile(script, configuration)
|
||||
|
||||
assert javaArchiveFile == '/config/mta/mta.jar'
|
||||
assert jlr.log.contains("SAP Multitarget Application Archive Builder file '/config/mta' retrieved from configuration.")
|
||||
}
|
||||
//
|
||||
|
||||
@Test
|
||||
void getJavaArchiveFileFailedTest() {
|
||||
|
||||
@ -85,7 +110,7 @@ class JavaArchiveDescriptorTest extends BasePipelineTest {
|
||||
javaArchive.getFile(script, configuration)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore('while compatibility code is not removed')
|
||||
void getJavaArchiveFileFromEnvironment_UnexpectedFormatTest() {
|
||||
|
||||
thrown.expect(AbortException)
|
||||
@ -96,7 +121,7 @@ class JavaArchiveDescriptorTest extends BasePipelineTest {
|
||||
javaArchive.getFile(script, configuration)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore('while compatibility code is not removed')
|
||||
void getJavaArchiveFileFromConfiguration_UnexpectedFormatTest() {
|
||||
|
||||
thrown.expect(AbortException)
|
||||
@ -180,6 +205,18 @@ class JavaArchiveDescriptorTest extends BasePipelineTest {
|
||||
}
|
||||
}
|
||||
|
||||
private getEnvVarsWithCompatibility(Map m) {
|
||||
|
||||
if(m.script.contains('JAVA_HOME')) {
|
||||
return '/env/java'
|
||||
} else if(m.script.contains('MTA_JAR_LOCATION')) {
|
||||
return '/env/mta'
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
private getUnexpectedFormatEnvVars(Map m) {
|
||||
|
||||
if(m.script.contains('JAVA_HOME')) {
|
||||
@ -190,6 +227,7 @@ class JavaArchiveDescriptorTest extends BasePipelineTest {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
private getNoEnvVars(Map m) {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user