1 package org.apache.archiva.metadata.repository.storage.maven2;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.archiva.configuration.ArchivaConfiguration;
23 import org.apache.archiva.metadata.model.ProjectVersionMetadata;
24 import org.apache.archiva.metadata.repository.filter.AllFilter;
25 import org.apache.archiva.metadata.repository.filter.Filter;
26 import org.apache.archiva.metadata.repository.storage.ReadMetadataRequest;
27 import org.apache.archiva.metadata.repository.storage.RepositoryStorageRuntimeException;
28 import org.apache.archiva.proxy.common.WagonFactory;
29 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.junit.runner.RunWith;
33 import org.springframework.test.context.ContextConfiguration;
35 import javax.inject.Inject;
36 import javax.inject.Named;
39 @RunWith ( ArchivaSpringJUnit4ClassRunner.class )
40 @ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
41 public class Maven2RepositoryMetadataResolverManagedReleaseTest
42 extends Maven2RepositoryMetadataResolverTest
44 private static final Filter<String> ALL = new AllFilter<String>();
47 @Named ( value = "repositoryStorage#maven2" )
48 private Maven2RepositoryStorage storage;
50 private static final String TEST_REPO_ID = "test";
52 private static final String TEST_REMOTE_REPO_ID = "central";
54 private static final String ASF_SCM_CONN_BASE = "scm:svn:http://svn.apache.org/repos/asf/";
56 private static final String ASF_SCM_DEV_CONN_BASE = "scm:svn:https://svn.apache.org/repos/asf/";
58 private static final String ASF_SCM_VIEWVC_BASE = "http://svn.apache.org/viewvc/";
60 private static final String TEST_SCM_CONN_BASE = "scm:svn:http://svn.example.com/repos/";
62 private static final String TEST_SCM_DEV_CONN_BASE = "scm:svn:https://svn.example.com/repos/";
64 private static final String TEST_SCM_URL_BASE = "http://svn.example.com/repos/";
66 private static final String EMPTY_MD5 = "d41d8cd98f00b204e9800998ecf8427e";
68 private static final String EMPTY_SHA1 = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
71 private ArchivaConfiguration configuration;
73 private WagonFactory wagonFactory;
82 testRepo.setReleases( true );
83 testRepo.setSnapshots( false );
85 configuration.save( c );
87 assertFalse( c.getManagedRepositories().get( 0 ).isSnapshots() );
88 assertTrue( c.getManagedRepositories().get( 0 ).isReleases() );
94 public void testModelWithJdkProfileActivation()
97 // skygo IMHO must fail because TEST_REPO_ID ( is snap ,no release) and we seek for a snapshot
99 ReadMetadataRequest readMetadataRequest =
100 new ReadMetadataRequest().repositoryId( TEST_REPO_ID ).namespace( "org.apache.maven" ).projectId(
101 "maven-archiver" ).projectVersion( "2.4.1" );
103 ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest );
106 @Test ( expected = RepositoryStorageRuntimeException.class )
108 public void testGetProjectVersionMetadataForTimestampedSnapshotMissingMetadata()
111 ReadMetadataRequest readMetadataRequest =
112 new ReadMetadataRequest().repositoryId( TEST_REPO_ID ).namespace( "com.example.test" ).projectId(
113 "missing-metadata" ).projectVersion( "1.0-SNAPSHOT" );
114 storage.readProjectVersionMetadata( readMetadataRequest );
117 @Test ( expected = RepositoryStorageRuntimeException.class )
119 public void testGetProjectVersionMetadataForTimestampedSnapshotMalformedMetadata()
122 ReadMetadataRequest readMetadataRequest =
123 new ReadMetadataRequest().repositoryId( TEST_REPO_ID ).namespace( "com.example.test" ).projectVersion(
124 "malformed-metadata" ).projectVersion( "1.0-SNAPSHOT" );
125 storage.readProjectVersionMetadata( readMetadataRequest );
128 @Test ( expected = RepositoryStorageRuntimeException.class )
130 public void testGetProjectVersionMetadataForTimestampedSnapshot()
133 super.testGetProjectVersionMetadataForTimestampedSnapshot();
137 @Test ( expected = RepositoryStorageRuntimeException.class )
139 public void testGetProjectVersionMetadataForTimestampedSnapshotIncompleteMetadata()
142 super.testGetProjectVersionMetadataForTimestampedSnapshotIncompleteMetadata();