1 package org.apache.archiva.rest.services;
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
21 import org.apache.archiva.maven2.model.Artifact;
22 import org.apache.archiva.rest.api.services.MergeRepositoriesService;
23 import org.apache.commons.io.FileUtils;
24 import static org.assertj.core.api.Assertions.assertThat;
25 import org.junit.After;
26 import org.junit.Before;
27 import org.junit.Test;
30 import java.util.List;
33 * @author Olivier Lamy
35 public class MergeRepositoriesServiceTest
36 extends AbstractArchivaRestTest
39 private static final String TEST_REPOSITORY = "test-repository";
41 private File repo = new File( System.getProperty( "builddir" ), "test-repository" );
43 private File repoStage = new File( System.getProperty( "builddir" ), "test-repository-stage" );
46 public void getMergeConflictedArtifacts()
49 MergeRepositoriesService service = getMergeRepositoriesService( authorizationHeader );
51 List<Artifact> artifactMetadatas = service.getMergeConflictedArtifacts( TEST_REPOSITORY + "-stage",
54 log.info( "conflicts: {}", artifactMetadatas );
56 assertThat( artifactMetadatas ).isNotNull().isNotEmpty().hasSize( 8 );
63 String mergedArtifactPath =
64 "org/apache/felix/org.apache.felix.bundlerepository/1.6.4/org.apache.felix.bundlerepository-1.6.4.jar";
65 String mergedArtifactPomPath =
66 "org/apache/felix/org.apache.felix.bundlerepository/1.6.4/org.apache.felix.bundlerepository-1.6.4.pom";
68 assertTrue( new File( repoStage, mergedArtifactPath ).exists() );
69 assertTrue( new File( repoStage, mergedArtifactPomPath ).exists() );
71 MergeRepositoriesService service = getMergeRepositoriesService( authorizationHeader );
73 service.mergeRepositories( TEST_REPOSITORY + "-stage", TEST_REPOSITORY, true );
75 assertTrue( new File( repo, mergedArtifactPath ).exists() );
76 assertTrue( new File( repo, mergedArtifactPomPath ).exists() );
80 public void deleteStageRepo()
83 waitForScanToComplete( TEST_REPOSITORY );
85 deleteTestRepo( TEST_REPOSITORY );
87 FileUtils.deleteDirectory( repo );
88 FileUtils.deleteDirectory( repoStage );
92 public void createStageRepo()
95 FileUtils.copyDirectory( new File( System.getProperty( "basedir" ), "src/test/repo-with-osgi" ), repo );
96 FileUtils.copyDirectory( new File( System.getProperty( "basedir" ), "src/test/repo-with-osgi-stage" ),
99 createStagedNeededRepo( TEST_REPOSITORY, repo.getAbsolutePath(), true );