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