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.metadata.model.ProjectVersionMetadata;
23 import org.apache.archiva.metadata.repository.filter.AllFilter;
24 import org.apache.archiva.metadata.repository.filter.Filter;
25 import org.apache.archiva.metadata.repository.storage.ReadMetadataRequest;
26 import org.apache.archiva.metadata.repository.storage.RepositoryStorageRuntimeException;
27 import org.apache.archiva.repository.RepositoryRegistry;
28 import org.junit.Before;
29 import org.junit.Test;
31 import javax.inject.Inject;
32 import javax.inject.Named;
34 public class Maven2RepositoryMetadataResolverManagedSnapshotTest
35 extends Maven2RepositoryMetadataResolverTest
37 private static final Filter<String> ALL = new AllFilter<String>();
40 @Named ( "repositoryStorage#maven2")
41 private Maven2RepositoryStorage storage;
44 RepositoryRegistry repositoryRegistry;
46 private static final String TEST_REPO_ID = "test";
48 private static final String TEST_REMOTE_REPO_ID = "central";
50 private static final String ASF_SCM_CONN_BASE = "scm:svn:http://svn.apache.org/repos/asf/";
52 private static final String ASF_SCM_DEV_CONN_BASE = "scm:svn:https://svn.apache.org/repos/asf/";
54 private static final String ASF_SCM_VIEWVC_BASE = "http://svn.apache.org/viewvc/";
56 private static final String TEST_SCM_CONN_BASE = "scm:svn:http://svn.example.com/repos/";
58 private static final String TEST_SCM_DEV_CONN_BASE = "scm:svn:https://svn.example.com/repos/";
60 private static final String TEST_SCM_URL_BASE = "http://svn.example.com/repos/";
62 private static final String EMPTY_MD5 = "d41d8cd98f00b204e9800998ecf8427e";
65 private static final String EMPTY_SHA1 = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
75 testRepo.setReleases( false );
76 testRepo.setSnapshots( true );
78 configuration.save( c );
80 repositoryRegistry.reload();
82 assertTrue( c.getManagedRepositories().get( 0 ).isSnapshots() );
83 assertFalse( c.getManagedRepositories().get( 0 ).isReleases() );
86 @Test (expected = RepositoryStorageRuntimeException.class)
88 public void testModelWithJdkProfileActivation()
91 // skygo IMHO must fail because TEST_REPO_ID ( is snap ,no release) and we seek for a snapshot
93 ReadMetadataRequest readMetadataRequest =
94 new ReadMetadataRequest().repositoryId( TEST_REPO_ID ).namespace( "org.apache.maven" ).projectId(
95 "maven-archiver" ).projectVersion( "2.4.1" );
97 ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest );
100 @Test (expected = RepositoryStorageRuntimeException.class)
102 public void testGetProjectVersionMetadataForMislocatedPom()
105 ReadMetadataRequest readMetadataRequest =
106 new ReadMetadataRequest().repositoryId( TEST_REPO_ID ).namespace( "com.example.test" ).projectId(
107 "mislocated-pom" ).projectVersion( "1.0" );
108 storage.readProjectVersionMetadata( readMetadataRequest );
114 public void testGetProjectVersionMetadata()
117 // super test is on release
120 @Test (expected = RepositoryStorageRuntimeException.class)
122 public void testGetProjectVersionMetadataForInvalidPom()
125 ReadMetadataRequest readMetadataRequest =
126 new ReadMetadataRequest().repositoryId( TEST_REPO_ID ).namespace( "com.example.test" ).projectId(
127 "invalid-pom" ).projectVersion( "1.0" );
128 storage.readProjectVersionMetadata( readMetadataRequest );
131 @Test (expected = RepositoryStorageRuntimeException.class)
133 public void testGetProjectVersionMetadataForMissingPom()
136 ReadMetadataRequest readMetadataRequest =
137 new ReadMetadataRequest().repositoryId( TEST_REPO_ID ).namespace( "com.example.test" ).projectId(
138 "missing-pom" ).projectVersion( "1.0" );
139 storage.readProjectVersionMetadata( readMetadataRequest );