2018-02-07 14:17:33 +02:00
|
|
|
package com.sap.piper.versioning
|
|
|
|
|
|
|
|
import org.junit.Before
|
|
|
|
import org.junit.Rule
|
|
|
|
import org.junit.Test
|
|
|
|
import org.junit.rules.RuleChain
|
2018-08-31 10:22:43 +02:00
|
|
|
|
2018-05-30 12:58:52 +02:00
|
|
|
import util.BasePiperTest
|
2018-02-07 14:17:33 +02:00
|
|
|
import util.JenkinsReadMavenPomRule
|
2018-08-31 10:22:43 +02:00
|
|
|
import util.JenkinsReadYamlRule
|
2018-02-07 14:17:33 +02:00
|
|
|
import util.JenkinsShellCallRule
|
|
|
|
import util.Rules
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals
|
|
|
|
|
2018-05-30 12:58:52 +02:00
|
|
|
class MavenArtifactVersioningTest extends BasePiperTest{
|
2018-02-07 14:17:33 +02:00
|
|
|
|
2018-03-06 14:28:57 +02:00
|
|
|
Map dockerParameters
|
|
|
|
def commonPipelineEnvironment
|
|
|
|
|
2018-02-07 14:17:33 +02:00
|
|
|
MavenArtifactVersioning av
|
|
|
|
|
2019-01-22 10:19:28 +02:00
|
|
|
JenkinsShellCallRule shellRule = new JenkinsShellCallRule(this)
|
2018-02-07 14:17:33 +02:00
|
|
|
|
|
|
|
@Rule
|
2018-05-30 12:58:52 +02:00
|
|
|
public RuleChain ruleChain = Rules
|
|
|
|
.getCommonRules(this)
|
2018-08-31 10:22:43 +02:00
|
|
|
.around(new JenkinsReadYamlRule(this))
|
2019-01-22 10:19:28 +02:00
|
|
|
.around(shellRule)
|
2018-08-31 14:13:11 +02:00
|
|
|
.around(new JenkinsReadMavenPomRule(this, 'test/resources/versioning/MavenArtifactVersioning'))
|
2018-02-07 14:17:33 +02:00
|
|
|
|
|
|
|
@Before
|
2018-03-06 14:28:57 +02:00
|
|
|
void init() {
|
|
|
|
dockerParameters = [:]
|
|
|
|
|
|
|
|
helper.registerAllowedMethod("dockerExecute", [Map.class, Closure.class],
|
|
|
|
{ parameters, closure ->
|
|
|
|
dockerParameters = parameters
|
|
|
|
closure()
|
|
|
|
})
|
2018-02-07 14:17:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void testVersioning() {
|
2018-05-30 12:58:52 +02:00
|
|
|
av = new MavenArtifactVersioning(nullScript, [filePath: 'pom.xml'])
|
2018-02-07 14:17:33 +02:00
|
|
|
assertEquals('1.2.3', av.getVersion())
|
|
|
|
av.setVersion('1.2.3-20180101')
|
2019-01-22 10:19:28 +02:00
|
|
|
assertEquals('mvn --file \'pom.xml\' --batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn versions:set -DnewVersion=1.2.3-20180101 -DgenerateBackupPoms=false', shellRule.shell[0])
|
2018-02-07 14:17:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void testVersioningCustomFilePathSnapshot() {
|
2018-05-30 12:58:52 +02:00
|
|
|
av = new MavenArtifactVersioning(nullScript, [filePath: 'snapshot/pom.xml'])
|
2018-02-07 14:17:33 +02:00
|
|
|
assertEquals('1.2.3', av.getVersion())
|
|
|
|
av.setVersion('1.2.3-20180101')
|
2019-01-22 10:19:28 +02:00
|
|
|
assertEquals('mvn --file \'snapshot/pom.xml\' --batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn versions:set -DnewVersion=1.2.3-20180101 -DgenerateBackupPoms=false', shellRule.shell[0])
|
2018-02-07 14:17:33 +02:00
|
|
|
}
|
|
|
|
}
|