View Javadoc
1   package org.apache.archiva.metadata.repository.storage.maven2;
2   
3   /*
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
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
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
19   * under the License.
20   */
21  
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.junit.Before;
28  import org.junit.Test;
29  
30  import javax.inject.Inject;
31  import javax.inject.Named;
32  
33  public class Maven2RepositoryMetadataResolverManagedSnapshotTest
34      extends Maven2RepositoryMetadataResolverTest
35  {
36      private static final Filter<String> ALL = new AllFilter<String>();
37  
38      @Inject
39      @Named ( "repositoryStorage#maven2")
40      private Maven2RepositoryStorage storage;
41  
42      private static final String TEST_REPO_ID = "test";
43  
44      private static final String TEST_REMOTE_REPO_ID = "central";
45  
46      private static final String ASF_SCM_CONN_BASE = "scm:svn:http://svn.apache.org/repos/asf/";
47  
48      private static final String ASF_SCM_DEV_CONN_BASE = "scm:svn:https://svn.apache.org/repos/asf/";
49  
50      private static final String ASF_SCM_VIEWVC_BASE = "http://svn.apache.org/viewvc/";
51  
52      private static final String TEST_SCM_CONN_BASE = "scm:svn:http://svn.example.com/repos/";
53  
54      private static final String TEST_SCM_DEV_CONN_BASE = "scm:svn:https://svn.example.com/repos/";
55  
56      private static final String TEST_SCM_URL_BASE = "http://svn.example.com/repos/";
57  
58      private static final String EMPTY_MD5 = "d41d8cd98f00b204e9800998ecf8427e";
59  
60  
61      private static final String EMPTY_SHA1 = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
62  
63  
64      @Before
65      @Override
66      public void setUp()
67          throws Exception
68      {
69          super.setUp();
70  
71          testRepo.setReleases( false );
72          testRepo.setSnapshots( true );
73  
74          configuration.save( c );
75  
76          assertTrue( c.getManagedRepositories().get( 0 ).isSnapshots() );
77          assertFalse( c.getManagedRepositories().get( 0 ).isReleases() );
78      }
79  
80      @Test (expected = RepositoryStorageRuntimeException.class)
81      @Override
82      public void testModelWithJdkProfileActivation()
83          throws Exception
84      {
85          // skygo IMHO must fail because TEST_REPO_ID ( is snap ,no release) and we seek for a snapshot
86  
87          ReadMetadataRequest readMetadataRequest =
88              new ReadMetadataRequest().repositoryId( TEST_REPO_ID ).namespace( "org.apache.maven" ).projectId(
89                  "maven-archiver" ).projectVersion( "2.4.1" );
90  
91          ProjectVersionMetadata metadata = storage.readProjectVersionMetadata( readMetadataRequest );
92      }
93  
94      @Test (expected = RepositoryStorageRuntimeException.class)
95      @Override
96      public void testGetProjectVersionMetadataForMislocatedPom()
97          throws Exception
98      {
99          ReadMetadataRequest readMetadataRequest =
100             new ReadMetadataRequest().repositoryId( TEST_REPO_ID ).namespace( "com.example.test" ).projectId(
101                 "mislocated-pom" ).projectVersion( "1.0" );
102         storage.readProjectVersionMetadata( readMetadataRequest );
103 
104     }
105 
106     @Test
107     @Override
108     public void testGetProjectVersionMetadata()
109         throws Exception
110     {
111         // super test is on release
112     }
113 
114     @Test (expected = RepositoryStorageRuntimeException.class)
115     @Override
116     public void testGetProjectVersionMetadataForInvalidPom()
117         throws Exception
118     {
119         ReadMetadataRequest readMetadataRequest =
120             new ReadMetadataRequest().repositoryId( TEST_REPO_ID ).namespace( "com.example.test" ).projectId(
121                 "invalid-pom" ).projectVersion( "1.0" );
122         storage.readProjectVersionMetadata( readMetadataRequest );
123     }
124 
125     @Test (expected = RepositoryStorageRuntimeException.class)
126     @Override
127     public void testGetProjectVersionMetadataForMissingPom()
128         throws Exception
129     {
130         ReadMetadataRequest readMetadataRequest =
131             new ReadMetadataRequest().repositoryId( TEST_REPO_ID ).namespace( "com.example.test" ).projectId(
132                 "missing-pom" ).projectVersion( "1.0" );
133         storage.readProjectVersionMetadata( readMetadataRequest );
134     }
135 }