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;
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;
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;
/**
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
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;
@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()
{
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
{
<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>
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;
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 )
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