[MRM-9] test invalid source snapshot metadata

git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@373022 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2006-01-27 23:15:17 +00:00
parent d215b81192
commit fa1de2a3e6
4 changed files with 79 additions and 6 deletions

View File

@ -227,7 +227,7 @@ public class DefaultRepositoryConverter
if ( file.exists() )
{
Metadata metadata = readMetadata( file );
result |= validateMetadata( metadata, repositoryMetadata, artifact, reporter );
result = result && validateMetadata( metadata, repositoryMetadata, artifact, reporter );
}
return result;
@ -276,7 +276,7 @@ public class DefaultRepositoryConverter
i.hasNext() && !foundVersion; )
{
String version = (String) i.next();
if ( version.equals( artifact.getVersion() ) )
if ( version.equals( artifact.getBaseVersion() ) )
{
foundVersion = true;
}
@ -292,13 +292,36 @@ public class DefaultRepositoryConverter
else
{
// snapshot metadata
if ( !metadata.getVersion().equals( artifact.getVersion() ) )
if ( !artifact.getBaseVersion().equals( metadata.getVersion() ) )
{
reporter.addFailure( artifact, getI18NString( key + "version" ) );
result = false;
}
// TODO: build number
if ( artifact.isSnapshot() )
{
Matcher matcher = Artifact.VERSION_FILE_PATTERN.matcher( artifact.getVersion() );
if ( matcher.matches() )
{
boolean correct = false;
if ( metadata.getVersioning() != null && metadata.getVersioning().getSnapshot() != null )
{
Snapshot snapshot = metadata.getVersioning().getSnapshot();
int build = Integer.valueOf( matcher.group( 3 ) ).intValue();
String ts = matcher.group( 2 );
if ( build == snapshot.getBuildNumber() && ts.equals( snapshot.getTimestamp() ) )
{
correct = true;
}
}
if ( !correct )
{
reporter.addFailure( artifact, getI18NString( key + "snapshot" ) );
result = false;
}
}
}
}
}
return result;

View File

@ -731,7 +731,6 @@ public class RepositoryConverterTest
{
// test artifact is not converted when source snapshot metadata is invalid and returns failure
/* TODO:
createModernSourceRepository();
Artifact artifact = createArtifact( "test", "incorrectSnapshotMetadata", "1.0.0-20060102.030405-6" );
@ -749,7 +748,6 @@ public class RepositoryConverterTest
File metadataFile =
new File( targetRepository.getBasedir(), targetRepository.pathOfRemoteRepositoryMetadata( metadata ) );
assertFalse( "Check metadata not created", metadataFile.exists() );
*/
}
public void testMergeArtifactMetadata()

View File

@ -0,0 +1,27 @@
<!--
~ Copyright 2005-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.
-->
<metadata>
<groupId>test</groupId>
<artifactId>incorrectSnapshotMetadata</artifactId>
<version>1.0.0-SNAPSHOT</version>
<versioning>
<snapshot>
<buildNumber>10</buildNumber>
<timestamp>20060102.040506</timestamp>
</snapshot>
</versioning>
</metadata>

View File

@ -0,0 +1,25 @@
<!--
~ Copyright 2005-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.
-->
<metadata>
<groupId>test</groupId>
<artifactId>incorrectSnapshotMetadata</artifactId>
<versioning>
<versions>
<version>1.0.0-SNAPSHOT</version>
</versions>
</versioning>
</metadata>