diff --git a/archiva-modules/plugins/metadata-store-jcr/pom.xml b/archiva-modules/plugins/metadata-store-jcr/pom.xml
index 72ee07e42..20df6c76f 100644
--- a/archiva-modules/plugins/metadata-store-jcr/pom.xml
+++ b/archiva-modules/plugins/metadata-store-jcr/pom.xml
@@ -56,25 +56,31 @@
jcr
2.0
+
+ org.apache.jackrabbit
+ jackrabbit-jcr-commons
+ ${jackrabbit.version}
+
org.apache.jackrabbit
jackrabbit-core
${jackrabbit.version}
-
+ test
+
commons-logging
commons-logging
-
- org.apache.derby
- derby
-
-
- org.apache.jackrabbit
- jackrabbit-text-extractors
-
+
+
+
+ src/test/filtered-resources
+ true
+
+
+
diff --git a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java
index 0bbdb48b3..cd21eeb3e 100644
--- a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java
+++ b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java
@@ -36,11 +36,9 @@ import org.apache.archiva.metadata.repository.MetadataRepository;
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;
@@ -91,25 +89,26 @@ public class JcrMetadataRepository
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/" );
diff --git a/archiva-modules/plugins/metadata-store-jcr/src/test/filtered-resources/META-INF/spring-context.xml b/archiva-modules/plugins/metadata-store-jcr/src/test/filtered-resources/META-INF/spring-context.xml
new file mode 100644
index 000000000..43f6d0829
--- /dev/null
+++ b/archiva-modules/plugins/metadata-store-jcr/src/test/filtered-resources/META-INF/spring-context.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepositoryTest.java b/archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepositoryTest.java
index e3b2c92f8..e62d56a19 100644
--- a/archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepositoryTest.java
+++ b/archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepositoryTest.java
@@ -21,6 +21,7 @@ package org.apache.archiva.metadata.repository.jcr;
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;
@@ -40,18 +41,11 @@ public class JcrMetadataRepositoryTest
Map 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();
@@ -61,6 +55,15 @@ public class JcrMetadataRepositoryTest
// ignore
}
+ this.repository = jcrMetadataRepository;
+ }
+
+ @Override
+ protected void tearDown()
+ throws Exception
+ {
jcrMetadataRepository.close();
+
+ super.tearDown();
}
}