From: Martin Stockhammer Date: Wed, 21 Jun 2017 22:37:51 +0000 (+0200) Subject: Fixing tests and path for jcr oak X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=96843bd488656a61a2ab374cc404fadf2819737d;p=archiva.git Fixing tests and path for jcr oak --- 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 65e1acec8..097838001 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; /** 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 f98b79bd1..e3fa80bf2 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"> - - - - - \ 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 5efabdfad..c364efe74 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 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 { diff --git a/archiva-modules/plugins/repository-statistics/pom.xml b/archiva-modules/plugins/repository-statistics/pom.xml index ccbdbfc49..23cc847fa 100644 --- a/archiva-modules/plugins/repository-statistics/pom.xml +++ b/archiva-modules/plugins/repository-statistics/pom.xml @@ -65,6 +65,16 @@ xercesImpl test + + org.apache.jackrabbit + jackrabbit-jcr-commons + 2.15.2 + + + org.apache.archiva + metadata-store-jcr + test + 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 1a46b8727..6094a631c 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