From 5f939ed28586926b706d616c511d37a055f951bc Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Sat, 19 Dec 2009 23:56:41 +0000 Subject: [PATCH] [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 --- .../apache/maven/it/IntegrationTestSuite.java | 1 + ...500NoUpdateOfTimestampedSnapshotsTest.java | 129 ++++++++++++++++++ .../src/test/resources/mng-4500/pom.xml | 65 +++++++++ .../dep-0.1-20091219.230823-1.jar | Bin 0 -> 1989 bytes .../dep-0.1-20091219.230823-1.pom | 38 ++++++ .../dep/0.1-SNAPSHOT/maven-metadata.xml | 13 ++ .../resources/mng-4500/settings-template.xml | 45 ++++++ 7 files changed, 291 insertions(+) create mode 100644 its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4500NoUpdateOfTimestampedSnapshotsTest.java create mode 100644 its/core-it-suite/src/test/resources/mng-4500/pom.xml create mode 100644 its/core-it-suite/src/test/resources/mng-4500/repo/org/apache/maven/its/mng4500/dep/0.1-SNAPSHOT/dep-0.1-20091219.230823-1.jar create mode 100644 its/core-it-suite/src/test/resources/mng-4500/repo/org/apache/maven/its/mng4500/dep/0.1-SNAPSHOT/dep-0.1-20091219.230823-1.pom create mode 100644 its/core-it-suite/src/test/resources/mng-4500/repo/org/apache/maven/its/mng4500/dep/0.1-SNAPSHOT/maven-metadata.xml create mode 100644 its/core-it-suite/src/test/resources/mng-4500/settings-template.xml diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java index 8f894aadf7..0ddb87e7de 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java @@ -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 ); diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4500NoUpdateOfTimestampedSnapshotsTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4500NoUpdateOfTimestampedSnapshotsTest.java new file mode 100644 index 0000000000..55ee39cc74 --- /dev/null +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4500NoUpdateOfTimestampedSnapshotsTest.java @@ -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 MNG-4500. + * + * @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(); + } + } + +} diff --git a/its/core-it-suite/src/test/resources/mng-4500/pom.xml b/its/core-it-suite/src/test/resources/mng-4500/pom.xml new file mode 100644 index 0000000000..ec95966cd6 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4500/pom.xml @@ -0,0 +1,65 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng4500 + test + 0.1 + + Maven Integration Test :: MNG-4500 + + 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. + + + + + org.apache.maven.its.mng4500 + dep + 0.1-SNAPSHOT + + + + + + + org.apache.maven.its.plugins + maven-it-plugin-dependency-resolution + 2.1-SNAPSHOT + + target/classpath.txt + 1 + + + + test + validate + + test + + + + + + + diff --git a/its/core-it-suite/src/test/resources/mng-4500/repo/org/apache/maven/its/mng4500/dep/0.1-SNAPSHOT/dep-0.1-20091219.230823-1.jar b/its/core-it-suite/src/test/resources/mng-4500/repo/org/apache/maven/its/mng4500/dep/0.1-SNAPSHOT/dep-0.1-20091219.230823-1.jar new file mode 100644 index 0000000000000000000000000000000000000000..bb648e340b9a1724f9dfe6d99017416e9179e663 GIT binary patch literal 1989 zcmWIWW@h1H00ADxDb`>Hl;8x?zOEsTx}JV+`TuQ}lbAEG>!4=~NPm6TC&YjTl)^*}wf3hTOikS8R zm5QBnx`TwhgMv%uYONKK;TD=~93)yJd^+eeP{zx+*z3R}zjc1=1nRohg?pKuC@{8d zu3#>X(~Hw%fH@1(_58@r%1taw&4c>^Q?U-F;{2j?y~KjV2W8KxEF=jv7D=9Gqb=g%<^*r)ta ze%Xq4x2S~Rr9o4L7UfRL4G`YOwIr}FZbs_d2H#%J$k4y zqmN3xdg~I7dY?L1X`B-Hx$m{9>jyTgmGcr^TO;NbU!FGg0BdZBEywMk2!qrc0k^9b zS8TkdVC~p)eb2JEm5LM3Yv*y z*PWub8zxBIV*5UoG2VEMDWhsYXl#+1(J9%;x37eE9pBgzljU}CjXGmdsRWykbUnkh zsO!u3-7lScylTO`kk((5LwLjAKEVQ22 zZX0R7_f6enMPA&aoM;lP4@=&Cidu`%!UqCUd%0&cm;*(r0CstT-d`;Dl`k%Mq#at=9@H zO1&S)bqZTPc$c4wbn^n6$}=h9U(Lu=R0U;L{d?hoGAlf{v@*>y@&(Z~E( zrm=!991z3@b6evPS_Kv9a@WKdxW0U&3YGGaIjugQ?26=pj2!WCxzlE!8- tOotY=h>*peS`n5^2bSq*AxqE;AWINwH^7^f4P+iW5ZVK4i2_y-4*+mQo&^8^ literal 0 HcmV?d00001 diff --git a/its/core-it-suite/src/test/resources/mng-4500/repo/org/apache/maven/its/mng4500/dep/0.1-SNAPSHOT/dep-0.1-20091219.230823-1.pom b/its/core-it-suite/src/test/resources/mng-4500/repo/org/apache/maven/its/mng4500/dep/0.1-SNAPSHOT/dep-0.1-20091219.230823-1.pom new file mode 100644 index 0000000000..c26528cc73 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4500/repo/org/apache/maven/its/mng4500/dep/0.1-SNAPSHOT/dep-0.1-20091219.230823-1.pom @@ -0,0 +1,38 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng4500 + dep + 0.1-SNAPSHOT + jar + + Maven Integration Test :: MNG-4500 + + + + maven-core-it + file:///${basedir}/repo + + + diff --git a/its/core-it-suite/src/test/resources/mng-4500/repo/org/apache/maven/its/mng4500/dep/0.1-SNAPSHOT/maven-metadata.xml b/its/core-it-suite/src/test/resources/mng-4500/repo/org/apache/maven/its/mng4500/dep/0.1-SNAPSHOT/maven-metadata.xml new file mode 100644 index 0000000000..c1ec8c490e --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4500/repo/org/apache/maven/its/mng4500/dep/0.1-SNAPSHOT/maven-metadata.xml @@ -0,0 +1,13 @@ + + + org.apache.maven.its.mng4500 + dep + 0.1-SNAPSHOT + + + 20091219.230823 + 1 + + 20091219230823 + + diff --git a/its/core-it-suite/src/test/resources/mng-4500/settings-template.xml b/its/core-it-suite/src/test/resources/mng-4500/settings-template.xml new file mode 100644 index 0000000000..dd8cfd62a9 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4500/settings-template.xml @@ -0,0 +1,45 @@ + + + + + + + + maven-core-it-repo + + + maven-core-it + http://localhost:@port@/repo + + false + + + + always + ignore + + + + + + + maven-core-it-repo + +