1 package org.apache.archiva.indexer.maven;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.archiva.indexer.ArchivaIndexingContext;
23 import org.apache.archiva.repository.ManagedRepository;
24 import org.apache.archiva.repository.features.IndexCreationFeature;
25 import org.apache.archiva.repository.maven2.MavenManagedRepository;
26 import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
27 import org.junit.Test;
28 import org.junit.runner.RunWith;
29 import org.springframework.test.context.ContextConfiguration;
31 import javax.inject.Inject;
34 import java.nio.file.Files;
35 import java.nio.file.Path;
36 import java.nio.file.Paths;
38 import static org.junit.Assert.*;
40 @RunWith( ArchivaSpringJUnit4ClassRunner.class )
41 @ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
42 public class MavenIndexManagerTest {
45 MavenIndexManager mavenIndexManager;
50 public void pack() throws Exception {
54 public void scan() throws Exception {
58 public void update() throws Exception {
62 public void addArtifactsToIndex() throws Exception {
66 public void removeArtifactsFromIndex() throws Exception {
70 public void supportsRepository() throws Exception {
74 public void createContext() throws Exception {
75 MavenManagedRepository repository = new MavenManagedRepository("test-repo", "Test Repo", Paths.get("target/repositories"));
76 repository.setLocation(new URI("test-repo"));
77 IndexCreationFeature icf = repository.getFeature(IndexCreationFeature.class).get();
78 icf.setIndexPath(new URI(".index-test"));
79 ArchivaIndexingContext ctx = mavenIndexManager.createContext(repository);
81 assertEquals(repository, ctx.getRepository());
82 assertEquals("test-repo", ctx.getId());
83 Path indexPath = Paths.get("target/repositories/test-repo/.index-test");
84 assertEquals(indexPath.toAbsolutePath(), Paths.get(ctx.getPath()).toAbsolutePath());
85 assertTrue(Files.exists(indexPath));