1 package org.apache.archiva.metadata.repository.jcr;
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 com.google.common.base.Objects;
23 import org.apache.archiva.metadata.model.MetadataFacetFactory;
24 import org.apache.archiva.metadata.repository.AbstractMetadataRepositoryTest;
25 import org.apache.commons.io.FileUtils;
26 import org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException;
27 import org.junit.After;
28 import org.junit.Before;
29 import org.junit.BeforeClass;
30 import org.springframework.context.ApplicationContext;
33 import java.io.IOException;
35 import javax.inject.Inject;
36 import javax.jcr.Repository;
37 import javax.jcr.RepositoryException;
38 import javax.jcr.Session;
40 public class JcrMetadataRepositoryTest
41 extends AbstractMetadataRepositoryTest
43 private JcrMetadataRepository jcrMetadataRepository;
46 private ApplicationContext applicationContext;
48 private static Repository jcrRepository;
51 public static void setupSpec() throws IOException, InvalidFileStoreVersionException
53 File directory = new File( "target/test-repositories" );
54 if ( directory.exists() )
56 FileUtils.deleteDirectory( directory );
58 RepositoryFactory factory = new RepositoryFactory();
59 factory.setRepositoryPath( directory.getPath() );
60 jcrRepository = factory.createRepository();
72 Map<String, MetadataFacetFactory> factories = createTestMetadataFacetFactories();
74 // TODO: probably don't need to use Spring for this
75 jcrMetadataRepository = new JcrMetadataRepository( factories, jcrRepository );
79 Session session = jcrMetadataRepository.getJcrSession();
81 // set up namespaces, etc.
82 JcrMetadataRepository.initialize( session );
84 // removing content is faster than deleting and re-copying the files from target/jcr
85 session.getRootNode().getNode( "repositories" ).remove();
87 catch ( RepositoryException e )
92 this.repository = jcrMetadataRepository;
98 public void tearDown()
101 jcrMetadataRepository.close();