You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ol...@apache.org on 2017/06/23 23:06:59 UTC

[10/13] archiva git commit: Fixing tests and path for jcr oak

Fixing tests and path for jcr oak


Project: http://git-wip-us.apache.org/repos/asf/archiva/repo
Commit: http://git-wip-us.apache.org/repos/asf/archiva/commit/96843bd4
Tree: http://git-wip-us.apache.org/repos/asf/archiva/tree/96843bd4
Diff: http://git-wip-us.apache.org/repos/asf/archiva/diff/96843bd4

Branch: refs/heads/feature/jcr_oak
Commit: 96843bd488656a61a2ab374cc404fadf2819737d
Parents: 7d2cc26
Author: Martin Stockhammer <ma...@apache.org>
Authored: Thu Jun 22 00:37:51 2017 +0200
Committer: olivier lamy <ol...@apache.org>
Committed: Sat Jun 24 09:05:49 2017 +1000

----------------------------------------------------------------------
 .../repository/jcr/RepositoryFactory.java       | 31 ++++++++++++--------
 .../META-INF/spring-context.xml                 |  6 ----
 .../jcr/JcrMetadataRepositoryTest.java          | 27 ++++++++++++-----
 .../plugins/repository-statistics/pom.xml       | 10 +++++++
 .../JcrRepositoryStatisticsGatheringTest.java   | 19 ++++++------
 5 files changed, 59 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/archiva/blob/96843bd4/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/RepositoryFactory.java
----------------------------------------------------------------------
diff --git a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/RepositoryFactory.java b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/RepositoryFactory.java
index 65e1ace..0978380 100644
--- a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/RepositoryFactory.java
+++ b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/RepositoryFactory.java
@@ -1,14 +1,29 @@
 package org.apache.archiva.metadata.repository.jcr;
 
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
+/*
+ * 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.
+ */
+
 import com.google.common.collect.ImmutableSet;
-import com.google.common.util.concurrent.MoreExecutors;
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.oak.Oak;
 import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.jcr.Jcr;
-import org.apache.jackrabbit.oak.plugins.index.IndexConstants;
 import org.apache.jackrabbit.oak.plugins.index.IndexUtils;
 import org.apache.jackrabbit.oak.plugins.index.lucene.ExtractedTextCache;
 import org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier;
@@ -16,12 +31,9 @@ import org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker;
 import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider;
 import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider;
 import org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.DocumentQueue;
-import org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.ExternalObserverBuilder;
 import org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.LocalIndexObserver;
 import org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndexFactory;
 import org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory;
-import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneInitializerHelper;
-import org.apache.jackrabbit.oak.segment.SegmentNodeStore;
 import org.apache.jackrabbit.oak.segment.SegmentNodeStoreBuilders;
 import org.apache.jackrabbit.oak.segment.file.FileStore;
 import org.apache.jackrabbit.oak.segment.file.FileStoreBuilder;
@@ -44,18 +56,13 @@ import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.util.concurrent.Executor;
 import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
 import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NAME;
 import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.INCLUDE_PROPERTY_TYPES;
 
 /**

http://git-wip-us.apache.org/repos/asf/archiva/blob/96843bd4/archiva-modules/plugins/metadata-store-jcr/src/test/filtered-resources/META-INF/spring-context.xml
----------------------------------------------------------------------
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
index f98b79b..e3fa80b 100644
--- 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
@@ -22,11 +22,5 @@
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
 
-  <bean id="repositoryFactory" class="org.apache.archiva.metadata.repository.jcr.RepositoryFactory" >
-    <property name="storeType" value="oak-segment-tar" />
-  </bean>
 
-  <bean id="repository" class="org.apache.archiva.metadata.repository.jcr.RepositoryFactory" factory-method="createRepository"
-    factory-bean="repositoryFactory">
-  </bean>
 </beans>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/archiva/blob/96843bd4/archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepositoryTest.java
----------------------------------------------------------------------
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 5efabdf..c364efe 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
@@ -22,12 +22,15 @@ package org.apache.archiva.metadata.repository.jcr;
 import org.apache.archiva.metadata.model.MetadataFacetFactory;
 import org.apache.archiva.metadata.repository.AbstractMetadataRepositoryTest;
 import org.apache.commons.io.FileUtils;
+import org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Test;
 import org.springframework.context.ApplicationContext;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.Map;
 import javax.inject.Inject;
 import javax.jcr.Repository;
@@ -42,6 +45,22 @@ public class JcrMetadataRepositoryTest
     @Inject
     private ApplicationContext applicationContext;
 
+    private static Repository jcrRepository;
+
+    @BeforeClass
+    public static void setupSpec() throws IOException, InvalidFileStoreVersionException
+    {
+        File directory = new File( "target/test-repositories" );
+        if ( directory.exists() )
+        {
+            FileUtils.deleteDirectory( directory );
+        }
+        RepositoryFactory factory = new RepositoryFactory();
+        factory.setRepositoryPath( directory.getPath() );
+        jcrRepository = factory.createRepository();
+
+    }
+
     @Before
     @Override
     public void setUp()
@@ -49,17 +68,11 @@ public class JcrMetadataRepositoryTest
     {
         super.setUp();
 
-        File directory = new File( "target/test-repositories" );
-        if ( directory.exists() )
-        {
-            FileUtils.deleteDirectory( directory );
-        }
 
         Map<String, MetadataFacetFactory> factories = createTestMetadataFacetFactories();
 
         // TODO: probably don't need to use Spring for this
-        Repository repository = applicationContext.getBean( Repository.class );
-        jcrMetadataRepository = new JcrMetadataRepository( factories, repository );
+        jcrMetadataRepository = new JcrMetadataRepository( factories, jcrRepository );
 
         try
         {

http://git-wip-us.apache.org/repos/asf/archiva/blob/96843bd4/archiva-modules/plugins/repository-statistics/pom.xml
----------------------------------------------------------------------
diff --git a/archiva-modules/plugins/repository-statistics/pom.xml b/archiva-modules/plugins/repository-statistics/pom.xml
index ccbdbfc..23cc847 100644
--- a/archiva-modules/plugins/repository-statistics/pom.xml
+++ b/archiva-modules/plugins/repository-statistics/pom.xml
@@ -65,6 +65,16 @@
       <artifactId>xercesImpl</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>jackrabbit-jcr-commons</artifactId>
+      <version>2.15.2</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>metadata-store-jcr</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>

http://git-wip-us.apache.org/repos/asf/archiva/blob/96843bd4/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/JcrRepositoryStatisticsGatheringTest.java
----------------------------------------------------------------------
diff --git a/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/JcrRepositoryStatisticsGatheringTest.java b/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/JcrRepositoryStatisticsGatheringTest.java
index 1a46b87..6094a63 100644
--- a/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/JcrRepositoryStatisticsGatheringTest.java
+++ b/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/JcrRepositoryStatisticsGatheringTest.java
@@ -22,9 +22,14 @@ package org.apache.archiva.metadata.repository.stats;
 import junit.framework.TestCase;
 import org.apache.archiva.metadata.repository.MetadataRepository;
 import org.apache.archiva.metadata.repository.RepositorySessionFactory;
+import org.apache.archiva.metadata.repository.jcr.RepositoryFactory;
+import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner;
 import org.apache.commons.io.FileUtils;
 import org.apache.jackrabbit.commons.JcrUtils;
-import org.apache.jackrabbit.core.TransientRepository;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
 
 import javax.inject.Inject;
 import javax.jcr.ImportUUIDBehavior;
@@ -42,12 +47,6 @@ import java.util.Calendar;
 import java.util.Date;
 import java.util.zip.GZIPInputStream;
 
-import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
 import static org.mockito.Mockito.*;
 
 @RunWith( ArchivaBlockJUnit4ClassRunner.class )
@@ -83,8 +82,10 @@ public class JcrRepositoryStatisticsGatheringTest
         assertTrue( confFile.exists() );
         assertFalse( dir.exists() );
 
-        TransientRepository repository = new TransientRepository( confFile, dir );
-        session = repository.login( new SimpleCredentials( "username", "password".toCharArray() ) );
+        RepositoryFactory repositoryFactory = new RepositoryFactory();
+        repositoryFactory.setRepositoryPath( dir.getPath() );
+        session = repositoryFactory.createRepository().login(new SimpleCredentials( "admin", "admin".toCharArray()));
+
 
         // TODO: perhaps have an archiva-jcr-utils module shared by these plugins that does this and can contain
         //      structure information