[MNG-4500] [regression] Maven checks for updates of timestamped snapshots

o Added IT

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@892534 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-12-19 23:56:41 +00:00
parent dbae04d079
commit 5f939ed285
7 changed files with 291 additions and 0 deletions

View File

@ -85,6 +85,7 @@ public class IntegrationTestSuite
// suite.addTestSuite( MavenIT0109ReleaseUpdateTest.class );
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
suite.addTestSuite( MavenITmng4500NoUpdateOfTimestampedSnapshotsTest.class );
suite.addTestSuite( MavenITmng4498IgnoreBrokenMetadataTest.class );
suite.addTestSuite( MavenITmng4489MirroringOfExtensionRepoTest.class );
suite.addTestSuite( MavenITmng4488ValidateExternalParenPomLenientTest.class );

View File

@ -0,0 +1,129 @@
package org.apache.maven.it;
/*
* 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.it.Verifier;
import org.apache.maven.it.util.ResourceExtractor;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
import org.mortbay.jetty.handler.DefaultHandler;
import org.mortbay.jetty.handler.HandlerList;
import org.mortbay.jetty.handler.ResourceHandler;
/**
* This is a test set for <a href="http://jira.codehaus.org/browse/MNG-4500">MNG-4500</a>.
*
* @author Benjamin Bentmann
*/
public class MavenITmng4500NoUpdateOfTimestampedSnapshotsTest
extends AbstractMavenIntegrationTestCase
{
public MavenITmng4500NoUpdateOfTimestampedSnapshotsTest()
{
super( "[2.0.3,3.0-alpha-1),[3.0-alpha-6,)" );
}
/**
* Test that timestamped snapshots are treated as immutable, i.e. Maven should never check for updates of them
* once downloaded from a remote repo regardless of the update policy.
*/
public void testit()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-4500" );
String pomUri = "/repo/org/apache/maven/its/mng4500/dep/0.1-SNAPSHOT/dep-0.1-20091219.230823-1.pom";
String jarUri = "/repo/org/apache/maven/its/mng4500/dep/0.1-SNAPSHOT/dep-0.1-20091219.230823-1.jar";
final List requestedUris = new ArrayList();
AbstractHandler logHandler = new AbstractHandler()
{
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
throws IOException, ServletException
{
requestedUris.add( request.getRequestURI() );
}
};
ResourceHandler repoHandler = new ResourceHandler();
repoHandler.setResourceBase( testDir.getAbsolutePath() );
HandlerList handlerList = new HandlerList();
handlerList.addHandler( logHandler );
handlerList.addHandler( repoHandler );
handlerList.addHandler( new DefaultHandler() );
Server server = new Server( 0 );
server.setHandler( handlerList );
server.start();
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
try
{
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
verifier.deleteArtifacts( "org.apache.maven.its.mng4500" );
Properties filterProps = verifier.newDefaultFilterProperties();
filterProps.setProperty( "@port@", Integer.toString( server.getConnectors()[0].getLocalPort() ) );
verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps );
verifier.getCliOptions().add( "-s" );
verifier.getCliOptions().add( "settings.xml" );
verifier.setLogFileName( "log-1.txt" );
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
List classpath = verifier.loadLines( "target/classpath.txt", "UTF-8" );
assertTrue( classpath.toString(), classpath.contains( "dep-0.1-SNAPSHOT.jar" ) );
assertTrue( requestedUris.toString(), requestedUris.contains( pomUri ) );
assertTrue( requestedUris.toString(), requestedUris.contains( jarUri ) );
requestedUris.clear();
verifier.setLogFileName( "log-2.txt" );
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
classpath = verifier.loadLines( "target/classpath.txt", "UTF-8" );
assertTrue( classpath.toString(), classpath.contains( "dep-0.1-SNAPSHOT.jar" ) );
assertFalse( requestedUris.toString(), requestedUris.contains( pomUri ) );
assertFalse( requestedUris.toString(), requestedUris.contains( jarUri ) );
}
finally
{
verifier.resetStreams();
server.stop();
}
}
}

View File

@ -0,0 +1,65 @@
<?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>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng4500</groupId>
<artifactId>test</artifactId>
<version>0.1</version>
<name>Maven Integration Test :: MNG-4500</name>
<description>
Test that timestamped snapshots are treated as immutable, i.e. Maven should never check for updates of them
once downloaded from a remote repo regardless of the update policy.
</description>
<dependencies>
<dependency>
<groupId>org.apache.maven.its.mng4500</groupId>
<artifactId>dep</artifactId>
<version>0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-dependency-resolution</artifactId>
<version>2.1-SNAPSHOT</version>
<configuration>
<testClassPath>target/classpath.txt</testClassPath>
<significantPathLevels>1</significantPathLevels>
</configuration>
<executions>
<execution>
<id>test</id>
<phase>validate</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,38 @@
<?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>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng4500</groupId>
<artifactId>dep</artifactId>
<version>0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Maven Integration Test :: MNG-4500</name>
<distributionManagement>
<repository>
<id>maven-core-it</id>
<url>file:///${basedir}/repo</url>
</repository>
</distributionManagement>
</project>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>org.apache.maven.its.mng4500</groupId>
<artifactId>dep</artifactId>
<version>0.1-SNAPSHOT</version>
<versioning>
<snapshot>
<timestamp>20091219.230823</timestamp>
<buildNumber>1</buildNumber>
</snapshot>
<lastUpdated>20091219230823</lastUpdated>
</versioning>
</metadata>

View File

@ -0,0 +1,45 @@
<?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.
-->
<settings>
<profiles>
<profile>
<id>maven-core-it-repo</id>
<repositories>
<repository>
<id>maven-core-it</id>
<url>http://localhost:@port@/repo</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<!-- The update policy should only apply to metadata but not to timestamped snapshots themselves! -->
<updatePolicy>always</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>maven-core-it-repo</activeProfile>
</activeProfiles>
</settings>