-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDEPLOY-118: integration test for
comparePomWithDeployed
.
- Loading branch information
Mathias de Riese
committed
Sep 29, 2022
1 parent
8ae58c8
commit 703652a
Showing
5 changed files
with
282 additions
and
0 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,72 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
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. | ||
--> | ||
|
||
<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>org.apache.maven.its.deploy.comparepom</groupId> | ||
<artifactId>test</artifactId> | ||
<version>1.0</version> | ||
<packaging>pom</packaging> | ||
|
||
<description> | ||
Tests deployment comparing with a deployed POM. Parameter comparePomWithDeployed. Modified POM! | ||
</description> | ||
|
||
<properties> | ||
<maven.test.skip>true</maven.test.skip> | ||
</properties> | ||
|
||
<distributionManagement> | ||
<repository> | ||
<id>it</id> | ||
<url>file:///${basedir}/repo</url> | ||
</repository> | ||
</distributionManagement> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<version>${m-deploy-p.version}</version> | ||
<configuration> | ||
<comparePomWithDeployed>true</comparePomWithDeployed> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>2.1</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
<configuration> | ||
<classifier>${classifier}</classifier> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</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,26 @@ | ||
# 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. | ||
|
||
invoker.debug = false | ||
|
||
invoker.goals = -Dclassifier=first clean deploy | ||
|
||
invoker.goals.2 = -Dclassifier=second clean deploy | ||
|
||
invoker.project.3 = altered-pom.xml | ||
invoker.goals.3 = -Dclassifier=third -Dm-deploy-p.version=${project.version} clean deploy | ||
invoker.buildResult.3 = failure |
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,72 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
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. | ||
--> | ||
|
||
<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>org.apache.maven.its.deploy.comparepom</groupId> | ||
<artifactId>test</artifactId> | ||
<version>1.0</version> | ||
<packaging>pom</packaging> | ||
|
||
<description> | ||
Tests deployment comparing with a deployed POM. Parameter comparePomWithDeployed. | ||
</description> | ||
|
||
<properties> | ||
<maven.test.skip>true</maven.test.skip> | ||
</properties> | ||
|
||
<distributionManagement> | ||
<repository> | ||
<id>it</id> | ||
<url>file:///${basedir}/repo</url> | ||
</repository> | ||
</distributionManagement> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<version>@project.version@</version> | ||
<configuration> | ||
<comparePomWithDeployed>true</comparePomWithDeployed> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>2.1</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
<configuration> | ||
<classifier>${classifier}</classifier> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</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,33 @@ | ||
/* | ||
* 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.io.*; | ||
import java.util.*; | ||
|
||
import org.codehaus.plexus.util.*; | ||
|
||
File file = new File( localRepositoryPath, "org/apache/maven/its/deploy/comparepom" ); | ||
System.out.println( "Deleting " + file ); | ||
FileUtils.deleteDirectory( file ); | ||
|
||
file = new File( basedir, "repo" ); | ||
System.out.println( "Deleting " + file ); | ||
FileUtils.deleteDirectory( file ); | ||
|
||
return true; |
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,79 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
class LogInspector | ||
{ | ||
File log; | ||
int index; | ||
LogInspector( File log ) | ||
{ | ||
this.log = log; | ||
this.index = 0; | ||
} | ||
boolean containsAfter( CharSequence text ) | ||
{ | ||
int newIdx = log.text.indexOf( text, index + 1 ) | ||
if ( newIdx > index) | ||
{ | ||
index = newIdx | ||
return true | ||
} | ||
return false | ||
} | ||
String toString () | ||
{ | ||
return "Log file ${log} after index ${index}." | ||
} | ||
} | ||
|
||
|
||
assert new File( basedir, "repo/org/apache/maven/its/deploy/comparepom/test/maven-metadata.xml" ).exists() | ||
assert new File( basedir, "repo/org/apache/maven/its/deploy/comparepom/test/1.0/test-1.0-first.jar" ).exists() | ||
assert new File( basedir, "repo/org/apache/maven/its/deploy/comparepom/test/1.0/test-1.0-second.jar").exists() | ||
|
||
File deployedPom = new File( basedir, "repo/org/apache/maven/its/deploy/comparepom/test/1.0/test-1.0.pom" ) | ||
assert deployedPom.exists() | ||
assert ! deployedPom.text.contains("Modified POM!") | ||
|
||
File installedPom = new File( localRepositoryPath, "org/apache/maven/its/deploy/comparepom/test/1.0/test-1.0.pom" ) | ||
assert installedPom.exists() | ||
assert installedPom.text.contains("Modified POM!") | ||
|
||
File buildLog = new File( basedir, 'build.log' ) | ||
assert buildLog.exists() | ||
|
||
// Inspect log | ||
LogInspector li = new LogInspector( buildLog ) | ||
String groupUrl = "file:///${basedir}/repo/org/apache/maven/its/deploy/comparepom" | ||
|
||
// First run: The POM tried to be downloaded and uploaded: | ||
assert li.containsAfter( "[INFO] Downloading from it: ${groupUrl}/test/1.0/test-1.0.pom" ) | ||
assert li.containsAfter( "[INFO] Uploaded to it: ${groupUrl}/test/1.0/test-1.0.pom" ) | ||
|
||
// After that, it is never tried to be uploaded: | ||
assert -1 == buildLog.text.indexOf( "[INFO] Uploading to it: ${groupUrl}/test/1.0/test-1.0.pom", li.index + 1 ) | ||
|
||
// Second run: POM is downloaded and not uploaded: | ||
assert li.containsAfter( "[INFO] Downloaded from it: ${groupUrl}/test/1.0/test-1.0.pom" ) | ||
assert li.containsAfter( "[INFO] Not deploying POM, since deployed POM is equal to current POM." ) | ||
|
||
// Third run: POM is downloaded, nothing is tried to be uploaded after that, and the build fails with error: | ||
assert li.containsAfter( "[INFO] Downloaded from it: ${groupUrl}/test/1.0/test-1.0.pom" ) | ||
assert -1 == buildLog.text.indexOf( "[INFO] Uploading to", li.index + 1 ) | ||
assert li.containsAfter( "[ERROR] Project version org.apache.maven.its.deploy.comparepom:test:1.0 already deployed with a differing POM." ) |