You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2020/11/01 11:36:42 UTC

[maven-studies] 15/15: Introduce mock repository manager to verify uploaded artifacts

This is an automated email from the ASF dual-hosted git repository.

rfscholte pushed a commit to branch maven-sign-plugin
in repository https://gitbox.apache.org/repos/asf/maven-studies.git

commit cab2710f1a037ee1d56f4934d7507c3dc3b99ee5
Author: rfscholte <rf...@apache.org>
AuthorDate: Sun Nov 1 12:33:55 2020 +0100

    Introduce mock repository manager to verify uploaded artifacts
---
 .gitignore                                         |  3 +++
 pom.xml                                            | 31 +++++++++++++++++++++-
 src/it/big-artifact/invoker.properties             | 23 ----------------
 src/it/{ => mrm}/settings.xml                      |  0
 src/it/pom-packaging/invoker.properties            | 21 ---------------
 src/it/{ => projects}/big-artifact/pom.xml         |  9 ++++++-
 src/it/{ => projects}/big-artifact/setup.groovy    |  0
 .../big-artifact/verify.groovy}                    | 16 +++++------
 src/it/{ => projects}/pom-packaging/pom.xml        |  9 ++++++-
 .../pom-packaging/verify.groovy}                   | 15 +++++------
 src/it/{ => projects}/standard-packaging/pom.xml   | 10 +++++--
 src/it/{ => projects}/standard-packaging/test.dat  |  0
 .../standard-packaging/verify.groovy}              | 18 +++++++------
 src/it/standard-packaging/invoker.properties       | 21 ---------------
 14 files changed, 82 insertions(+), 94 deletions(-)

diff --git a/.gitignore b/.gitignore
index e02456b..8614d5e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,6 @@
 target/
 .idea
 *.iml
+/.classpath
+/.project
+/.settings/
diff --git a/pom.xml b/pom.xml
index 923668a..6508132 100644
--- a/pom.xml
+++ b/pom.xml
@@ -158,9 +158,38 @@
               <debug>false</debug>
               <showErrors>true</showErrors>
               <showVersion>true</showVersion>
-              <streamLogs>true</streamLogs>
+              <goals>
+                <goal>deploy</goal>
+              </goals>
+              <projectsDirectory>src/it/projects</projectsDirectory>
+              <settingsFile>src/it/mrm/settings.xml</settingsFile>
+              <filterProperties>
+                <mrm.distribution.url>${mrm.distribution.url}</mrm.distribution.url>
+              </filterProperties>
             </configuration>
           </plugin>
+          <plugin>
+            <groupId>org.codehaus.mojo</groupId>
+            <artifactId>mrm-maven-plugin</artifactId>
+            <version>1.2.0</version>
+            <executions>
+              <execution>
+                <id>distribution</id>
+                <goals>
+                  <goal>start</goal>
+                  <goal>stop</goal>
+                </goals>
+                    <configuration>
+                      <propertyName>mrm.distribution.url</propertyName>
+                      <repositories>
+                        <hostedRepo>
+                          <target>target/hosted-repo</target>
+                        </hostedRepo>
+                      </repositories>
+                    </configuration>
+              </execution>
+            </executions>
+          </plugin>
         </plugins>
       </build>
     </profile>
diff --git a/src/it/big-artifact/invoker.properties b/src/it/big-artifact/invoker.properties
deleted file mode 100644
index a9f0e93..0000000
--- a/src/it/big-artifact/invoker.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# 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.goals = install --no-transfer-progress -Drevision=1.1.1-SNAPSHOT
-
-invoker.mavenOpts = -Dorg.slf4j.simpleLogger.showDateTime=true
-
diff --git a/src/it/settings.xml b/src/it/mrm/settings.xml
similarity index 100%
rename from src/it/settings.xml
rename to src/it/mrm/settings.xml
diff --git a/src/it/pom-packaging/invoker.properties b/src/it/pom-packaging/invoker.properties
deleted file mode 100644
index 1113391..0000000
--- a/src/it/pom-packaging/invoker.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# 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.goals = install --no-transfer-progress -Drevision=1.1.1-SNAPSHOT
-
diff --git a/src/it/big-artifact/pom.xml b/src/it/projects/big-artifact/pom.xml
similarity index 93%
rename from src/it/big-artifact/pom.xml
rename to src/it/projects/big-artifact/pom.xml
index 5b74862..1107d52 100644
--- a/src/it/big-artifact/pom.xml
+++ b/src/it/projects/big-artifact/pom.xml
@@ -26,8 +26,15 @@
 
   <groupId>test-group</groupId>
   <artifactId>big-artifact</artifactId>
-  <version>${revision}</version>
+  <version>1.0.0</version>
   <packaging>pom</packaging>
+  
+  <distributionManagement>
+    <repository>
+      <id>mrm</id>
+      <url>@mrm.distribution.url@</url>
+    </repository>
+  </distributionManagement>
 
   <build>
     <extensions>
diff --git a/src/it/big-artifact/setup.groovy b/src/it/projects/big-artifact/setup.groovy
similarity index 100%
copy from src/it/big-artifact/setup.groovy
copy to src/it/projects/big-artifact/setup.groovy
diff --git a/src/it/big-artifact/setup.groovy b/src/it/projects/big-artifact/verify.groovy
similarity index 65%
copy from src/it/big-artifact/setup.groovy
copy to src/it/projects/big-artifact/verify.groovy
index 73f1956..2fd8b6a 100644
--- a/src/it/big-artifact/setup.groovy
+++ b/src/it/projects/big-artifact/verify.groovy
@@ -19,14 +19,14 @@ import java.security.SecureRandom
  * under the License.
  *
  */
+def remoteRepo = new File(basedir, '../../hosted-repo')
 
+def gavFolder = new File(remoteRepo, 'test-group/big-artifact/1.0.0')
 
-def random = new Random();
-def buf = new byte[ 800 * 1024 ];
+def expectedSignedFiles = ['big-artifact-1.0.0.pom.asc',
+ 		 				   'big-artifact-1.0.0.dat.asc'] as Set
+					 
+def deployedSignedFiles = [] as Set
+gavFolder.eachFileMatch(groovy.io.FileType.FILES, ~/big-artifact-1\.0\.0.+\.asc/) { deployedSignedFiles << it.name } 
 
-new File( basedir, "test.dat" ).withOutputStream { out ->
-    1024.times {
-                random.nextBytes(buf)
-                out.write(buf)
-    }
-}
+assert deployedSignedFiles== expectedSignedFiles
diff --git a/src/it/pom-packaging/pom.xml b/src/it/projects/pom-packaging/pom.xml
similarity index 91%
rename from src/it/pom-packaging/pom.xml
rename to src/it/projects/pom-packaging/pom.xml
index 59a7df3..88b7bfd 100644
--- a/src/it/pom-packaging/pom.xml
+++ b/src/it/projects/pom-packaging/pom.xml
@@ -26,8 +26,15 @@
 
   <groupId>test-group</groupId>
   <artifactId>pom-packaging</artifactId>
-  <version>${revision}</version>
+  <version>1.0.0</version>
   <packaging>pom</packaging>
+  
+  <distributionManagement>
+    <repository>
+      <id>mrm</id>
+      <url>@mrm.distribution.url@</url>
+    </repository>
+  </distributionManagement>
 
   <build>
     <plugins>
diff --git a/src/it/big-artifact/setup.groovy b/src/it/projects/pom-packaging/verify.groovy
similarity index 67%
copy from src/it/big-artifact/setup.groovy
copy to src/it/projects/pom-packaging/verify.groovy
index 73f1956..46df6fb 100644
--- a/src/it/big-artifact/setup.groovy
+++ b/src/it/projects/pom-packaging/verify.groovy
@@ -19,14 +19,13 @@ import java.security.SecureRandom
  * under the License.
  *
  */
+def remoteRepo = new File(basedir, '../../hosted-repo')
 
+def gavFolder = new File(remoteRepo, 'test-group/pom-packaging/1.0.0')
 
-def random = new Random();
-def buf = new byte[ 800 * 1024 ];
+def expectedSignedFiles = ['pom-packaging-1.0.0.pom.asc'] as Set
+					 
+def deployedSignedFiles = [] as Set
+gavFolder.eachFileMatch(groovy.io.FileType.FILES, ~/pom-packaging-1\.0\.0.+\.asc/) { deployedSignedFiles << it.name } 
 
-new File( basedir, "test.dat" ).withOutputStream { out ->
-    1024.times {
-                random.nextBytes(buf)
-                out.write(buf)
-    }
-}
+assert deployedSignedFiles== expectedSignedFiles
diff --git a/src/it/standard-packaging/pom.xml b/src/it/projects/standard-packaging/pom.xml
similarity index 93%
rename from src/it/standard-packaging/pom.xml
rename to src/it/projects/standard-packaging/pom.xml
index 8fe32c0..a998a46 100644
--- a/src/it/standard-packaging/pom.xml
+++ b/src/it/projects/standard-packaging/pom.xml
@@ -26,11 +26,17 @@
 
   <groupId>test-group</groupId>
   <artifactId>standard-packaging</artifactId>
-  <version>${revision}</version>
+  <version>1.0.0</version>
 
+  <distributionManagement>
+    <repository>
+      <id>mrm</id>
+      <url>@mrm.distribution.url@</url>
+    </repository>
+  </distributionManagement>
+  
   <build>
     <plugins>
-
       <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>build-helper-maven-plugin</artifactId>
diff --git a/src/it/standard-packaging/test.dat b/src/it/projects/standard-packaging/test.dat
similarity index 100%
rename from src/it/standard-packaging/test.dat
rename to src/it/projects/standard-packaging/test.dat
diff --git a/src/it/big-artifact/setup.groovy b/src/it/projects/standard-packaging/verify.groovy
similarity index 60%
rename from src/it/big-artifact/setup.groovy
rename to src/it/projects/standard-packaging/verify.groovy
index 73f1956..e8d8cbd 100644
--- a/src/it/big-artifact/setup.groovy
+++ b/src/it/projects/standard-packaging/verify.groovy
@@ -19,14 +19,16 @@ import java.security.SecureRandom
  * under the License.
  *
  */
+def remoteRepo = new File(basedir, '../../hosted-repo')
 
+def gavFolder = new File(remoteRepo, 'test-group/standard-packaging/1.0.0')
 
-def random = new Random();
-def buf = new byte[ 800 * 1024 ];
+def expectedSignedFiles = ['standard-packaging-1.0.0.pom.asc',
+ 		 				   'standard-packaging-1.0.0.jar.asc',
+ 		 				   'standard-packaging-1.0.0.dat.asc',
+ 		 				   'standard-packaging-1.0.0-c1.dat.asc'] as Set
+					 
+def deployedSignedFiles = [] as Set
+gavFolder.eachFileMatch(groovy.io.FileType.FILES, ~/standard-packaging-1\.0\.0.+\.asc/) { deployedSignedFiles << it.name } 
 
-new File( basedir, "test.dat" ).withOutputStream { out ->
-    1024.times {
-                random.nextBytes(buf)
-                out.write(buf)
-    }
-}
+assert deployedSignedFiles== expectedSignedFiles
diff --git a/src/it/standard-packaging/invoker.properties b/src/it/standard-packaging/invoker.properties
deleted file mode 100644
index 1113391..0000000
--- a/src/it/standard-packaging/invoker.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# 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.goals = install --no-transfer-progress -Drevision=1.1.1-SNAPSHOT
-