You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gb...@apache.org on 2016/12/30 17:13:57 UTC

svn commit: r1776610 - in /maven/plugins/trunk/maven-dependency-plugin/src/it/projects: copy-from-remote-repository/ unpack-from-remote-repository/

Author: gboue
Date: Fri Dec 30 17:13:57 2016
New Revision: 1776610

URL: http://svn.apache.org/viewvc?rev=1776610&view=rev
Log:
Updating the tests so that they no longer rely on reading the logs, making them more robust: a setup script first deletes from the local repository the artifact that should be downloaded, then it is verified that they are present in the local repository after the build (thus verifying that they were correctly downloaded).

Added:
    maven/plugins/trunk/maven-dependency-plugin/src/it/projects/copy-from-remote-repository/setup.bsh   (with props)
    maven/plugins/trunk/maven-dependency-plugin/src/it/projects/copy-from-remote-repository/verify.bsh
      - copied, changed from r1776513, maven/plugins/trunk/maven-dependency-plugin/src/it/projects/copy-from-remote-repository/verify.groovy
    maven/plugins/trunk/maven-dependency-plugin/src/it/projects/unpack-from-remote-repository/setup.bsh   (with props)
    maven/plugins/trunk/maven-dependency-plugin/src/it/projects/unpack-from-remote-repository/verify.bsh
      - copied, changed from r1776513, maven/plugins/trunk/maven-dependency-plugin/src/it/projects/unpack-from-remote-repository/verify.groovy
Removed:
    maven/plugins/trunk/maven-dependency-plugin/src/it/projects/copy-from-remote-repository/verify.groovy
    maven/plugins/trunk/maven-dependency-plugin/src/it/projects/unpack-from-remote-repository/verify.groovy

Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/copy-from-remote-repository/setup.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/copy-from-remote-repository/setup.bsh?rev=1776610&view=auto
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/copy-from-remote-repository/setup.bsh (added)
+++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/copy-from-remote-repository/setup.bsh Fri Dec 30 17:13:57 2016
@@ -0,0 +1,41 @@
+/*
+ * 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 org.codehaus.plexus.util.*;
+
+String[] foldersToDelete = {
+    "org/apache/maven/its/dependency/fake-remote-copy"
+};
+
+try
+{
+    for ( String folderToDelete : foldersToDelete )
+    {
+        FileUtils.deleteDirectory( new File( localRepositoryPath, folderToDelete ) );
+    }
+}
+catch ( IOException e )
+{
+    e.printStackTrace();
+    return false;
+}
+
+return true;

Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/copy-from-remote-repository/setup.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/copy-from-remote-repository/setup.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/copy-from-remote-repository/verify.bsh (from r1776513, maven/plugins/trunk/maven-dependency-plugin/src/it/projects/copy-from-remote-repository/verify.groovy)
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/copy-from-remote-repository/verify.bsh?p2=maven/plugins/trunk/maven-dependency-plugin/src/it/projects/copy-from-remote-repository/verify.bsh&p1=maven/plugins/trunk/maven-dependency-plugin/src/it/projects/copy-from-remote-repository/verify.groovy&r1=1776513&r2=1776610&rev=1776610&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/copy-from-remote-repository/verify.groovy (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/copy-from-remote-repository/verify.bsh Fri Dec 30 17:13:57 2016
@@ -16,19 +16,27 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
+ 
 import java.io.*;
 
-File buildLog = new File( basedir, 'build.log' )
-assert buildLog.exists()
-String expectedDownloadingPattern = "Downloading.*: file:///" + basedir.getPath().replaceAll( "\\\\", "\\\\") +
-                                        "/repo/org/apache/maven/its/dependency/fake-remote-copy/1\\.0/fake-remote-copy-1\\.0\\.jar"
-String expectedDownloadedPattern = "Downloaded.*: file:///" + basedir.getPath().replaceAll( "\\\\", "\\\\") +
-                                       "/repo/org/apache/maven/its/dependency/fake-remote-copy/1\\.0/fake-remote-copy-1\\.0\\.jar"
-assert buildLog.text =~ expectedDownloadingPattern
-assert buildLog.text =~ expectedDownloadedPattern
+String[] expectedFiles = {
+    "org/apache/maven/its/dependency/fake-remote-copy/1.0/fake-remote-copy-1.0.jar"
+};
+
+for ( String expectedFile : expectedFiles )
+{
+    File file = new File( localRepositoryPath, expectedFile );
+    System.out.println( "Checking for existence of " + file );
+    if ( !file.isFile() )
+    {
+        throw new Exception( "Missing file " + file );
+    }
+}
 
-File copied = new File( basedir, 'target/dependency/fake-remote-copy-1.0.jar' )
-assert copied.exists()
+File copied = new File( basedir, "target/dependency/fake-remote-copy-1.0.jar" );
+if ( !copied.exists() )
+{
+    throw new Exception( "Missing file " + file );
+}
 
 return true;

Added: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/unpack-from-remote-repository/setup.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/unpack-from-remote-repository/setup.bsh?rev=1776610&view=auto
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/unpack-from-remote-repository/setup.bsh (added)
+++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/unpack-from-remote-repository/setup.bsh Fri Dec 30 17:13:57 2016
@@ -0,0 +1,41 @@
+/*
+ * 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 org.codehaus.plexus.util.*;
+
+String[] foldersToDelete = {
+    "org/apache/maven/its/dependency/fake-remote-unpack"
+};
+
+try
+{
+    for ( String folderToDelete : foldersToDelete )
+    {
+        FileUtils.deleteDirectory( new File( localRepositoryPath, folderToDelete ) );
+    }
+}
+catch ( IOException e )
+{
+    e.printStackTrace();
+    return false;
+}
+
+return true;

Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/unpack-from-remote-repository/setup.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/unpack-from-remote-repository/setup.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: maven/plugins/trunk/maven-dependency-plugin/src/it/projects/unpack-from-remote-repository/verify.bsh (from r1776513, maven/plugins/trunk/maven-dependency-plugin/src/it/projects/unpack-from-remote-repository/verify.groovy)
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/unpack-from-remote-repository/verify.bsh?p2=maven/plugins/trunk/maven-dependency-plugin/src/it/projects/unpack-from-remote-repository/verify.bsh&p1=maven/plugins/trunk/maven-dependency-plugin/src/it/projects/unpack-from-remote-repository/verify.groovy&r1=1776513&r2=1776610&rev=1776610&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/it/projects/unpack-from-remote-repository/verify.groovy (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/it/projects/unpack-from-remote-repository/verify.bsh Fri Dec 30 17:13:57 2016
@@ -19,16 +19,24 @@
 
 import java.io.*;
 
-File buildLog = new File( basedir, 'build.log' )
-assert buildLog.exists()
-String expectedDownloadingPattern = "Downloading.*: file:///" + basedir.getPath().replaceAll( "\\\\", "\\\\") +
-                                        "/repo/org/apache/maven/its/dependency/fake-remote-unpack/1\\.0/fake-remote-unpack-1\\.0\\.jar"
-String expectedDownloadedPattern = "Downloaded.*: file:///" + basedir.getPath().replaceAll( "\\\\", "\\\\") +
-                                       "/repo/org/apache/maven/its/dependency/fake-remote-unpack/1\\.0/fake-remote-unpack-1\\.0\\.jar"
-assert buildLog.text =~ expectedDownloadingPattern
-assert buildLog.text =~ expectedDownloadedPattern
+String[] expectedFiles = {
+    "org/apache/maven/its/dependency/fake-remote-unpack/1.0/fake-remote-unpack-1.0.jar"
+};
 
-File unpacked = new File( basedir, 'target/dependency/META-INF/MANIFEST.MF' )
-assert unpacked.exists()
+for ( String expectedFile : expectedFiles )
+{
+    File file = new File( localRepositoryPath, expectedFile );
+    System.out.println( "Checking for existence of " + file );
+    if ( !file.isFile() )
+    {
+        throw new Exception( "Missing file " + file );
+    }
+}
+
+File unpacked = new File( basedir, "target/dependency/META-INF/MANIFEST.MF" );
+if ( !unpacked.exists() )
+{
+    throw new Exception( "Missing file " + file );
+}
 
 return true;