<artifactId>jcr</artifactId>
<version>2.0</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-jcr-commons</artifactId>
+ <version>${jackrabbit.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-core</artifactId>
<version>${jackrabbit.version}</version>
- <!-- TODO: trim more, or look for a lighter container? -->
+ <scope>test</scope>
+ <!-- could trim more, but since it's just for test we don't need to worry -->
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
- <exclusion>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>jackrabbit-text-extractors</artifactId>
- </exclusion>
</exclusions>
</dependency>
</dependencies>
+ <build>
+ <testResources>
+ <testResource>
+ <directory>src/test/filtered-resources</directory>
+ <filtering>true</filtering>
+ </testResource>
+ </testResources>
+ </build>
</project>
import org.apache.archiva.metadata.repository.MetadataRepositoryException;
import org.apache.archiva.metadata.repository.MetadataResolutionException;
import org.apache.jackrabbit.commons.JcrUtils;
-import org.apache.jackrabbit.core.TransientRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
private static final Logger log = LoggerFactory.getLogger( JcrMetadataRepository.class );
- private static Repository repository;
+ /**
+ * @plexus.requirement
+ */
+ private Repository repository;
private Session session;
public JcrMetadataRepository()
+ {
+ }
+
+ public void login()
{
// TODO: need to close this at the end - do we need to add it in the API?
try
{
- // TODO: push this in from the test, and make it possible from the webapp
- if ( repository == null )
- {
- repository = new TransientRepository( new File( "src/test/repository.xml" ), new File( "target/jcr" ) );
- }
// TODO: shouldn't do this in constructor since it's a singleton
session = repository.login( new SimpleCredentials( "username", "password".toCharArray() ) );
- // TODO: try moving this into the repo instantiation
Workspace workspace = session.getWorkspace();
workspace.getNamespaceRegistry().registerNamespace( "archiva", "http://archiva.apache.org/jcr/" );
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <bean id="repository" class="org.apache.jackrabbit.core.RepositoryImpl" destroy-method="shutdown">
+ <constructor-arg ref="config"/>
+ </bean>
+ <bean id="config" class="org.apache.jackrabbit.core.config.RepositoryConfig" factory-method="create">
+ <constructor-arg value="${basedir}/src/test/repository.xml"/>
+ <constructor-arg value="${project.build.directory}/jcr"/>
+ </bean>
+</beans>
\ No newline at end of file
import org.apache.archiva.metadata.model.MetadataFacetFactory;
import org.apache.archiva.metadata.repository.AbstractMetadataRepositoryTest;
+import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.commons.io.FileUtils;
import java.util.Map;
Map<String, MetadataFacetFactory> factories = createTestMetadataFacetFactories();
- jcrMetadataRepository = new JcrMetadataRepository();
+ jcrMetadataRepository = (JcrMetadataRepository) lookup( MetadataRepository.class );
jcrMetadataRepository.setMetadataFacetFactories( factories );
+ jcrMetadataRepository.login();
- this.repository = jcrMetadataRepository;
- }
-
- @Override
- protected void tearDown()
- throws Exception
- {
- super.tearDown();
-
+ // removing content is faster than deleting and re-copying the files from target/jcr
try
{
jcrMetadataRepository.getJcrSession().getRootNode().getNode( "repositories" ).remove();
// ignore
}
+ this.repository = jcrMetadataRepository;
+ }
+
+ @Override
+ protected void tearDown()
+ throws Exception
+ {
jcrMetadataRepository.close();
+
+ super.tearDown();
}
}