mirror of
https://github.com/apache/maven.git
synced 2025-02-21 01:15:42 +00:00
[MNG-1908] add a test for SNAPSHOT updating when not using a timestamp
git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@469031 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8843a5e243
commit
6494bf9571
@ -0,0 +1,76 @@
|
||||
package org.apache.maven.integrationtests;
|
||||
|
||||
/*
|
||||
* Copyright 2004-2006 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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 junit.framework.TestCase;
|
||||
import org.apache.maven.it.Verifier;
|
||||
import org.apache.maven.it.util.FileUtils;
|
||||
import org.apache.maven.it.util.ResourceExtractor;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Test to verify that a snapshot can be updated, even if the
|
||||
*/
|
||||
public class MavenSnapshotUpdateITest
|
||||
extends TestCase /*extends AbstractMavenIntegrationTest*/
|
||||
{
|
||||
|
||||
/**
|
||||
* Test plugin configuration and goal configuration that overrides what the
|
||||
* mojo has specified.
|
||||
*/
|
||||
public void testSnapshotUpdated()
|
||||
throws Exception
|
||||
{
|
||||
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/snapshotUpdate" );
|
||||
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
|
||||
verifier.deleteArtifact( "org.apache.maven", "maven-core-it-support", "1.0-SNAPSHOT", "jar" );
|
||||
|
||||
// create a repository (TODO: into verifier)
|
||||
File repository = new File( testDir, "repository" );
|
||||
repository.mkdirs();
|
||||
|
||||
// create artifact in repository (TODO: into verifier)
|
||||
File artifact = new File( repository,
|
||||
"org/apache/maven/maven-core-it-support/1.0-SNAPSHOT/maven-core-it-support-1.0-SNAPSHOT.jar" );
|
||||
artifact.getParentFile().mkdirs();
|
||||
FileUtils.fileWrite( artifact.getAbsolutePath(), "originalArtifact" );
|
||||
verifier.assertArtifactNotPresent( "org.apache.maven", "maven-core-it-support", "1.0-SNAPSHOT", "jar" );
|
||||
|
||||
verifier.executeGoal( "package" );
|
||||
|
||||
verifier.assertArtifactPresent( "org.apache.maven", "maven-core-it-support", "1.0-SNAPSHOT", "jar" );
|
||||
verifier.assertArtifactContents( "org.apache.maven", "maven-core-it-support", "1.0-SNAPSHOT", "jar",
|
||||
"originalArtifact" );
|
||||
File localRepoFile =
|
||||
new File( verifier.getArtifactPath( "org.apache.maven", "maven-core-it-support", "1.0-SNAPSHOT", "jar" ) );
|
||||
// set in the past to ensure it is downloaded
|
||||
localRepoFile.setLastModified( System.currentTimeMillis() - 2000 );
|
||||
|
||||
FileUtils.fileWrite( artifact.getAbsolutePath(), "updatedArtifact" );
|
||||
verifier.executeGoal( "package" );
|
||||
|
||||
verifier.assertArtifactPresent( "org.apache.maven", "maven-core-it-support", "1.0-SNAPSHOT", "jar" );
|
||||
verifier.assertArtifactContents( "org.apache.maven", "maven-core-it-support", "1.0-SNAPSHOT", "jar",
|
||||
"updatedArtifact" );
|
||||
|
||||
verifier.verifyErrorFreeLog();
|
||||
verifier.resetStreams();
|
||||
System.out.println( "snapshotUpdate PASS" );
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
<!--
|
||||
~ Copyright 2004-2006 The Apache Software Foundation.
|
||||
~
|
||||
~ Licensed 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 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/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<name>Maven Integration Test :: snapshotUpdate</name>
|
||||
<groupId>org.apache.maven.its.snapshotUpdate</groupId>
|
||||
<artifactId>maven-it-snapshot-update</artifactId>
|
||||
<description>
|
||||
Downloads a snapshot dependency that was deployed with uniqueVersion = false, and checks it can be
|
||||
updated.
|
||||
</description>
|
||||
<version>1.0</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-core-it-support</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>it.snapshots</id>
|
||||
<url>file://localhost/${basedir}/repository</url>
|
||||
<snapshots>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
</project>
|
Loading…
x
Reference in New Issue
Block a user