forked from mojohaus/versions
-
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.
Fixing mojohaus#315: Guarding against newVersion or property being em…
…pty if the properties file is not provided
- Loading branch information
Showing
5 changed files
with
173 additions
and
1 deletion.
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
73 changes: 73 additions & 0 deletions
73
src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.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,73 @@ | ||
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.apache.maven.plugin.MojoExecutionException; | ||
import org.codehaus.mojo.versions.utils.BaseMojoTestCase; | ||
import org.junit.Test; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.containsString; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
/** | ||
* Basic tests for {@linkplain SetPropertyMojoTest}. | ||
* | ||
* @author Andrzej Jarmoniuk | ||
*/ | ||
public class SetPropertyMojoTest extends BaseMojoTestCase | ||
{ | ||
@Test | ||
public void testNullNewVersion() | ||
throws Exception | ||
{ | ||
SetPropertyMojo mojo = createMojo( "set-property", | ||
"src/test/resources/org/codehaus/mojo/set-property/null-new-version-pom.xml" ); | ||
assertThat( mojo.getProject().getProperties(), is( mojo.getProject().getModel().getProperties() ) ); | ||
try | ||
{ | ||
mojo.execute(); | ||
fail(); | ||
} | ||
catch ( MojoExecutionException e ) | ||
{ | ||
assertThat( e.getMessage(), | ||
containsString( "Invalid execution arguments: newVersion must not be empty" ) ); | ||
} | ||
} | ||
|
||
@Test | ||
public void testNullProperty() | ||
throws Exception | ||
{ | ||
SetPropertyMojo mojo = createMojo( "set-property", | ||
"src/test/resources/org/codehaus/mojo/set-property/null-property-pom.xml" ); | ||
try | ||
{ | ||
mojo.execute(); | ||
fail(); | ||
} | ||
catch ( MojoExecutionException e ) | ||
{ | ||
assertThat( e.getMessage(), | ||
containsString( "Invalid execution arguments: property must not be empty" ) ); | ||
} | ||
} | ||
} |
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
31 changes: 31 additions & 0 deletions
31
src/test/resources/org/codehaus/mojo/set-property/null-new-version-pom.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,31 @@ | ||
<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>default-group</groupId> | ||
<artifactId>default-artifact</artifactId> | ||
<version>1.0</version> | ||
<packaging>pom</packaging> | ||
|
||
<properties> | ||
<dummy-api-version>1.0.0</dummy-api-version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>localhost</groupId> | ||
<artifactId>dummy-api</artifactId> | ||
<version>${dummy-api-version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>versions-maven-plugin</artifactId> | ||
<configuration> | ||
<property>dummy-api-version</property> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
31 changes: 31 additions & 0 deletions
31
src/test/resources/org/codehaus/mojo/set-property/null-property-pom.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,31 @@ | ||
<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>default-group</groupId> | ||
<artifactId>default-artifact</artifactId> | ||
<version>1.0</version> | ||
<packaging>pom</packaging> | ||
|
||
<properties> | ||
<dummy-api-version>1.0.0</dummy-api-version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>localhost</groupId> | ||
<artifactId>dummy-api</artifactId> | ||
<version>${dummy-api-version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>versions-maven-plugin</artifactId> | ||
<configuration> | ||
<newVersion>2.0.0</newVersion> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |