-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#454: Applying bound artifact versions to UpdatePropertiesMojo, Updat…
…ePropertyMojo + adding it tests for resolve-ranges and update-parent
- Loading branch information
Showing
15 changed files
with
430 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:resolve-ranges | ||
invoker.mavenOpts = -DallowMajorUpdates=false |
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,20 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>localhost</groupId> | ||
<artifactId>test-artifact</artifactId> | ||
<version>1.0.0</version> | ||
|
||
<properties> | ||
<ver>[1.0.0,)</ver> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>localhost</groupId> | ||
<artifactId>dummy-parent5</artifactId> | ||
<version>${ver}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
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,3 @@ | ||
pom = new File( basedir, "pom.xml" ).text | ||
|
||
assert !( pom =~ /2.0.0-rc1/ ) |
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,2 @@ | ||
invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:update-parent | ||
invoker.mavenOpts = -DallowMajorUpdates=false |
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,14 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>test-artifact</artifactId> | ||
<version>1.0.0</version> | ||
|
||
<parent> | ||
<groupId>localhost</groupId> | ||
<artifactId>dummy-parent5</artifactId> | ||
<version>1.0.0</version> | ||
</parent> | ||
|
||
</project> |
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,3 @@ | ||
pom = new File( basedir, "pom.xml" ).text | ||
|
||
assert !( pom =~ /2.0.0-rc1/ ) |
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
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
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
33 changes: 33 additions & 0 deletions
33
src/test/java/org/codehaus/mojo/versions/ResolveRangesMojoTest.java
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,33 @@ | ||
package org.codehaus.mojo.versions; | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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. | ||
*/ | ||
|
||
import org.junit.Test; | ||
|
||
/** | ||
* Unit tests for {@link ResolveRangesMojo} | ||
*/ | ||
public class ResolveRangesMojoTest | ||
{ | ||
@Test | ||
public void testDependencyRangesMajorUpdatesFalse() | ||
{ | ||
|
||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTest.java
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,70 @@ | ||
package org.codehaus.mojo.versions; | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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. | ||
*/ | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
|
||
import org.codehaus.mojo.versions.change.VersionChange; | ||
import org.hamcrest.Matchers; | ||
import org.junit.Test; | ||
|
||
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
/** | ||
* Unit tests for {@link UpdatePropertiesMojo} | ||
*/ | ||
public class UpdatePropertiesMojoTest extends UpdatePropertiesMojoTestBase | ||
{ | ||
@Test | ||
public void testAllowMajorUpdates() throws Exception | ||
{ | ||
Files.copy( Paths.get( "src/test/resources/org/codehaus/mojo/update-properties/issue-454-pom.xml" ), | ||
Paths.get( pomDir.toString(), "pom.xml" ), REPLACE_EXISTING ); | ||
setUpMojo( "update-properties" ).execute(); | ||
assertThat( changeRecorder.getChanges(), Matchers.hasItem( new VersionChange( "default-group", | ||
"default-artifact", "1.0.0", "2.0.0-M1" ) ) ); | ||
} | ||
|
||
@Test | ||
public void testAllowMinorUpdates() throws Exception | ||
{ | ||
Files.copy( Paths.get( "src/test/resources/org/codehaus/mojo/update-properties/issue-454-pom.xml" ), | ||
Paths.get( pomDir.toString(), "pom.xml" ), REPLACE_EXISTING ); | ||
UpdatePropertiesMojo mojo = setUpMojo( "update-properties" ); | ||
mojo.allowMajorUpdates = false; | ||
mojo.execute(); | ||
assertThat( changeRecorder.getChanges(), Matchers.hasItem( new VersionChange( "default-group", | ||
"default-artifact", "1.0.0", "1.1.0-alpha" ) ) ); | ||
} | ||
|
||
@Test | ||
public void testAllowIncrementalUpdates() throws Exception | ||
{ | ||
Files.copy( Paths.get( "src/test/resources/org/codehaus/mojo/update-properties/issue-454-pom.xml" ), | ||
Paths.get( pomDir.toString(), "pom.xml" ), REPLACE_EXISTING ); | ||
UpdatePropertiesMojo mojo = setUpMojo( "update-properties" ); | ||
mojo.allowMajorUpdates = false; | ||
mojo.allowMinorUpdates = false; | ||
mojo.execute(); | ||
assertThat( changeRecorder.getChanges(), Matchers.hasItem( new VersionChange( "default-group", | ||
"default-artifact", "1.0.0", "1.0.1-rc1" ) ) ); | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTestBase.java
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,84 @@ | ||
package org.codehaus.mojo.versions; | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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. | ||
*/ | ||
|
||
import java.nio.file.Path; | ||
import java.util.HashMap; | ||
|
||
import org.apache.maven.artifact.metadata.ArtifactMetadataSource; | ||
import org.apache.maven.plugin.Mojo; | ||
import org.apache.maven.plugin.testing.AbstractMojoTestCase; | ||
import org.apache.maven.plugin.testing.MojoRule; | ||
import org.apache.maven.plugin.testing.stubs.StubArtifactRepository; | ||
import org.codehaus.mojo.versions.utils.TestChangeRecorder; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
|
||
import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; | ||
import static org.codehaus.mojo.versions.utils.TestUtils.createTempDir; | ||
import static org.codehaus.mojo.versions.utils.TestUtils.tearDownTempDir; | ||
|
||
/** | ||
* Base class for {@link UpdatePropertiesMojo} and {@link UpdatePropertyMojo} test suites | ||
*/ | ||
public abstract class UpdatePropertiesMojoTestBase extends AbstractMojoTestCase | ||
{ | ||
@Rule | ||
public MojoRule mojoRule = new MojoRule( this ); | ||
protected Path pomDir; | ||
protected ArtifactMetadataSource artifactMetadataSource; | ||
protected TestChangeRecorder changeRecorder; | ||
|
||
@Before | ||
public void setUp() throws Exception | ||
{ | ||
super.setUp(); | ||
pomDir = createTempDir( "update-property" ); | ||
changeRecorder = new TestChangeRecorder(); | ||
artifactMetadataSource = mockArtifactMetadataSource( new HashMap<String, String[]>() | ||
{{ | ||
put( "default-artifact", new String[] {"1.0.0", "1.0.1-rc1", "1.1.0-alpha", "2.0.0-M1"} ); | ||
}} ); | ||
} | ||
|
||
@After | ||
public void tearDown() throws Exception | ||
{ | ||
try | ||
{ | ||
tearDownTempDir( pomDir ); | ||
} | ||
finally | ||
{ | ||
super.tearDown(); | ||
} | ||
} | ||
|
||
@SuppressWarnings( "unchecked" ) | ||
protected <T extends Mojo> T setUpMojo( String goal ) throws Exception | ||
{ | ||
T mojo = (T) mojoRule.lookupConfiguredMojo( pomDir.toFile(), goal ); | ||
setVariableValueToObject( mojo, "localRepository", new StubArtifactRepository( pomDir.toString() ) ); | ||
setVariableValueToObject( mojo, "artifactMetadataSource", artifactMetadataSource ); | ||
setVariableValueToObject( mojo, "changeRecorder", changeRecorder ); | ||
setVariableValueToObject( mojo, "generateBackupPoms", false ); | ||
return (T) mojo; | ||
} | ||
} |
Oops, something went wrong.