Skip to content

Commit 703652a

Browse files
author
Mathias de Riese
committed
MDEPLOY-118: integration test for comparePomWithDeployed.
1 parent 8ae58c8 commit 703652a

File tree

5 files changed

+282
-0
lines changed

5 files changed

+282
-0
lines changed

Diff for: src/it/compare-pom/altered-pom.xml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<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">
23+
<modelVersion>4.0.0</modelVersion>
24+
25+
<groupId>org.apache.maven.its.deploy.comparepom</groupId>
26+
<artifactId>test</artifactId>
27+
<version>1.0</version>
28+
<packaging>pom</packaging>
29+
30+
<description>
31+
Tests deployment comparing with a deployed POM. Parameter comparePomWithDeployed. Modified POM!
32+
</description>
33+
34+
<properties>
35+
<maven.test.skip>true</maven.test.skip>
36+
</properties>
37+
38+
<distributionManagement>
39+
<repository>
40+
<id>it</id>
41+
<url>file:///${basedir}/repo</url>
42+
</repository>
43+
</distributionManagement>
44+
45+
<build>
46+
<plugins>
47+
<plugin>
48+
<groupId>org.apache.maven.plugins</groupId>
49+
<artifactId>maven-deploy-plugin</artifactId>
50+
<version>${m-deploy-p.version}</version>
51+
<configuration>
52+
<comparePomWithDeployed>true</comparePomWithDeployed>
53+
</configuration>
54+
</plugin>
55+
<plugin>
56+
<groupId>org.apache.maven.plugins</groupId>
57+
<artifactId>maven-jar-plugin</artifactId>
58+
<version>2.1</version>
59+
<executions>
60+
<execution>
61+
<goals>
62+
<goal>jar</goal>
63+
</goals>
64+
<configuration>
65+
<classifier>${classifier}</classifier>
66+
</configuration>
67+
</execution>
68+
</executions>
69+
</plugin>
70+
</plugins>
71+
</build>
72+
</project>

Diff for: src/it/compare-pom/invoker.properties

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
invoker.debug = false
19+
20+
invoker.goals = -Dclassifier=first clean deploy
21+
22+
invoker.goals.2 = -Dclassifier=second clean deploy
23+
24+
invoker.project.3 = altered-pom.xml
25+
invoker.goals.3 = -Dclassifier=third -Dm-deploy-p.version=${project.version} clean deploy
26+
invoker.buildResult.3 = failure

Diff for: src/it/compare-pom/pom.xml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<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">
23+
<modelVersion>4.0.0</modelVersion>
24+
25+
<groupId>org.apache.maven.its.deploy.comparepom</groupId>
26+
<artifactId>test</artifactId>
27+
<version>1.0</version>
28+
<packaging>pom</packaging>
29+
30+
<description>
31+
Tests deployment comparing with a deployed POM. Parameter comparePomWithDeployed.
32+
</description>
33+
34+
<properties>
35+
<maven.test.skip>true</maven.test.skip>
36+
</properties>
37+
38+
<distributionManagement>
39+
<repository>
40+
<id>it</id>
41+
<url>file:///${basedir}/repo</url>
42+
</repository>
43+
</distributionManagement>
44+
45+
<build>
46+
<plugins>
47+
<plugin>
48+
<groupId>org.apache.maven.plugins</groupId>
49+
<artifactId>maven-deploy-plugin</artifactId>
50+
<version>@project.version@</version>
51+
<configuration>
52+
<comparePomWithDeployed>true</comparePomWithDeployed>
53+
</configuration>
54+
</plugin>
55+
<plugin>
56+
<groupId>org.apache.maven.plugins</groupId>
57+
<artifactId>maven-jar-plugin</artifactId>
58+
<version>2.1</version>
59+
<executions>
60+
<execution>
61+
<goals>
62+
<goal>jar</goal>
63+
</goals>
64+
<configuration>
65+
<classifier>${classifier}</classifier>
66+
</configuration>
67+
</execution>
68+
</executions>
69+
</plugin>
70+
</plugins>
71+
</build>
72+
</project>

Diff for: src/it/compare-pom/setup.bsh

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import java.io.*;
21+
import java.util.*;
22+
23+
import org.codehaus.plexus.util.*;
24+
25+
File file = new File( localRepositoryPath, "org/apache/maven/its/deploy/comparepom" );
26+
System.out.println( "Deleting " + file );
27+
FileUtils.deleteDirectory( file );
28+
29+
file = new File( basedir, "repo" );
30+
System.out.println( "Deleting " + file );
31+
FileUtils.deleteDirectory( file );
32+
33+
return true;

Diff for: src/it/compare-pom/verify.groovy

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
class LogInspector
21+
{
22+
File log;
23+
int index;
24+
LogInspector( File log )
25+
{
26+
this.log = log;
27+
this.index = 0;
28+
}
29+
boolean containsAfter( CharSequence text )
30+
{
31+
int newIdx = log.text.indexOf( text, index + 1 )
32+
if ( newIdx > index)
33+
{
34+
index = newIdx
35+
return true
36+
}
37+
return false
38+
}
39+
String toString ()
40+
{
41+
return "Log file ${log} after index ${index}."
42+
}
43+
}
44+
45+
46+
assert new File( basedir, "repo/org/apache/maven/its/deploy/comparepom/test/maven-metadata.xml" ).exists()
47+
assert new File( basedir, "repo/org/apache/maven/its/deploy/comparepom/test/1.0/test-1.0-first.jar" ).exists()
48+
assert new File( basedir, "repo/org/apache/maven/its/deploy/comparepom/test/1.0/test-1.0-second.jar").exists()
49+
50+
File deployedPom = new File( basedir, "repo/org/apache/maven/its/deploy/comparepom/test/1.0/test-1.0.pom" )
51+
assert deployedPom.exists()
52+
assert ! deployedPom.text.contains("Modified POM!")
53+
54+
File installedPom = new File( localRepositoryPath, "org/apache/maven/its/deploy/comparepom/test/1.0/test-1.0.pom" )
55+
assert installedPom.exists()
56+
assert installedPom.text.contains("Modified POM!")
57+
58+
File buildLog = new File( basedir, 'build.log' )
59+
assert buildLog.exists()
60+
61+
// Inspect log
62+
LogInspector li = new LogInspector( buildLog )
63+
String groupUrl = "file:///${basedir}/repo/org/apache/maven/its/deploy/comparepom"
64+
65+
// First run: The POM tried to be downloaded and uploaded:
66+
assert li.containsAfter( "[INFO] Downloading from it: ${groupUrl}/test/1.0/test-1.0.pom" )
67+
assert li.containsAfter( "[INFO] Uploaded to it: ${groupUrl}/test/1.0/test-1.0.pom" )
68+
69+
// After that, it is never tried to be uploaded:
70+
assert -1 == buildLog.text.indexOf( "[INFO] Uploading to it: ${groupUrl}/test/1.0/test-1.0.pom", li.index + 1 )
71+
72+
// Second run: POM is downloaded and not uploaded:
73+
assert li.containsAfter( "[INFO] Downloaded from it: ${groupUrl}/test/1.0/test-1.0.pom" )
74+
assert li.containsAfter( "[INFO] Not deploying POM, since deployed POM is equal to current POM." )
75+
76+
// Third run: POM is downloaded, nothing is tried to be uploaded after that, and the build fails with error:
77+
assert li.containsAfter( "[INFO] Downloaded from it: ${groupUrl}/test/1.0/test-1.0.pom" )
78+
assert -1 == buildLog.text.indexOf( "[INFO] Uploading to", li.index + 1 )
79+
assert li.containsAfter( "[ERROR] Project version org.apache.maven.its.deploy.comparepom:test:1.0 already deployed with a differing POM." )

0 commit comments

Comments
 (0)