]> source.dussan.org Git - archiva.git/blob
4fd4bab269a74b8be3d8d55f8b582dd56f0fa978
[archiva.git] /
1 package org.apache.archiva.metadata.repository.file;
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.configuration.ArchivaConfiguration;
23 import org.apache.archiva.configuration.Configuration;
24 import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
25 import org.apache.archiva.metadata.model.MetadataFacetFactory;
26 import org.apache.archiva.metadata.repository.AbstractMetadataRepositoryTest;
27 import org.apache.archiva.metadata.repository.MetadataRepository;
28 import org.apache.archiva.metadata.repository.MetadataService;
29 import org.apache.archiva.metadata.repository.RepositorySessionFactory;
30 import org.junit.jupiter.api.BeforeEach;
31 import org.junit.jupiter.api.Disabled;
32
33 import java.nio.file.Files;
34 import java.nio.file.Path;
35 import java.nio.file.Paths;
36 import java.util.List;
37
38 import static org.mockito.Mockito.mock;
39 import static org.mockito.Mockito.when;
40
41 public class FileMetadataRepositoryTest
42     extends AbstractMetadataRepositoryTest
43 {
44
45     private FileMetadataRepository repository;
46     private RepositorySessionFactory sessionFactory = new FileRepositorySessionFactory();
47
48     @Override
49     protected MetadataRepository getRepository( )
50     {
51         return this.repository;
52     }
53
54     @Override
55     protected RepositorySessionFactory getSessionFactory( )
56     {
57         return this.sessionFactory;
58     }
59
60     @BeforeEach
61     @Override
62     public void setUp()
63         throws Exception
64     {
65         super.setUp();
66         assertMaxTries = 1;
67         assertRetrySleepMs = 10;
68
69         Path directory = Paths.get( "target/test-repositories" );
70         if (Files.exists(directory))
71         {
72             org.apache.archiva.common.utils.FileUtils.deleteDirectory( directory );
73         }
74         ArchivaConfiguration config = createTestConfiguration( directory );
75         List<MetadataFacetFactory> factories = createTestMetadataFacetFactories();
76         MetadataService metadataService = new MetadataService( );
77         metadataService.setMetadataFacetFactories( factories );
78
79         this.repository = new FileMetadataRepository( metadataService, config );
80     }
81
82     @Override
83     @Disabled
84     public void testGetArtifactsByProjectVersionMetadata()
85         throws Exception
86     {
87         // TODO not implemented
88     }
89
90     @Override
91     @Disabled
92     public void testGetArtifactsByProjectVersionMetadataNoRepository()
93         throws Exception
94     {
95         // TODO not implemented
96     }
97
98     @Override
99     @Disabled
100     public void testGetArtifactsByProjectVersionMetadataAllRepositories()
101         throws Exception
102     {
103         // TODO not implemented
104     }
105
106     @Override
107     @Disabled
108     public void testGetArtifactsByMetadataAllRepositories()
109         throws Exception
110     {
111         // TODO not implemented
112     }
113
114     @Override
115     @Disabled
116     public void testGetArtifactsByPropertySingleResult()
117         throws Exception
118     {
119         // TODO not implemented
120     }
121
122     @Override
123     @Disabled
124     public void testSearchArtifactsByKey()
125         throws Exception
126     {
127         // TODO not implemented
128     }
129
130     @Override
131     @Disabled
132     public void testSearchArtifactsByKeyExact()
133         throws Exception
134     {
135         // TODO not implemented
136     }
137
138     @Override
139     @Disabled
140     public void testSearchArtifactsFullText()
141         throws Exception
142     {
143         // TODO not implemented
144     }
145
146     @Override
147     @Disabled
148     public void testSearchArtifactsFullTextExact()
149         throws Exception
150     {
151         // TODO not implemented
152     }
153
154     @Override
155     @Disabled
156     public void testSearchArtifactsByFacetKeyAllRepos()
157         throws Exception
158     {
159         // TODO not implemented
160     }
161
162     @Override
163     @Disabled
164     public void testSearchArtifactsByFacetKey()
165         throws Exception
166     {
167         // TODO not implemented
168     }
169
170     @Override
171     @Disabled
172     public void testSearchArtifactsFullTextByFacet()
173         throws Exception
174     {
175         // TODO not implemented
176     }
177
178     protected static ArchivaConfiguration createTestConfiguration( Path directory )
179     {
180         ArchivaConfiguration config = mock( ArchivaConfiguration.class );
181         Configuration configData = new Configuration();
182         configData.addManagedRepository( createManagedRepository( TEST_REPO_ID, directory ) );
183         configData.addManagedRepository( createManagedRepository( "other-repo", directory ) );
184         when( config.getConfiguration() ).thenReturn( configData );
185         return config;
186     }
187
188     private static ManagedRepositoryConfiguration createManagedRepository( String repoId, Path directory )
189     {
190         ManagedRepositoryConfiguration managedRepository = new ManagedRepositoryConfiguration();
191         managedRepository.setId( repoId );
192         managedRepository.setLocation( directory.resolve( repoId ).toAbsolutePath().toString() );
193         return managedRepository;
194     }
195 }