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 org.fest.assertions.api.Assertions;
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 File repo = new File( System.getProperty( "builddir" ), "test-repository" );
41 private File repoStage = new File( System.getProperty( "builddir" ), "test-repository-stage" );
45 public void startServer()
49 FileUtils.copyDirectory( new File( System.getProperty( "basedir" ), "src/test/repo-with-osgi" ), repo );
50 FileUtils.copyDirectory( new File( System.getProperty( "basedir" ), "src/test/repo-with-osgi-stage" ),
58 public void stopServer()
61 // TODO delete repositories
63 FileUtils.deleteDirectory( repo );
64 FileUtils.deleteDirectory( repoStage );
68 public void getMergeConflictedArtifacts()
71 String testRepoId = "test-repository";
75 createStagedNeededRepo( testRepoId, repo.getAbsolutePath(), true );
77 MergeRepositoriesService service = getMergeRepositoriesService( authorizationHeader );
79 List<Artifact> artifactMetadatas = service.getMergeConflictedArtifacts( testRepoId + "-stage", testRepoId );
81 log.info( "conflicts: {}", artifactMetadatas );
83 Assertions.assertThat( artifactMetadatas ).isNotNull().isNotEmpty().hasSize( 8 );
89 log.error( e.getMessage(), e );
94 deleteTestRepo( testRepoId );
102 String testRepoId = "test-repository";
105 createStagedNeededRepo( testRepoId, repo.getAbsolutePath(), true );
107 String mergedArtifactPath =
108 "org/apache/felix/org.apache.felix.bundlerepository/1.6.4/org.apache.felix.bundlerepository-1.6.4.jar";
109 String mergedArtifactPomPath =
110 "org/apache/felix/org.apache.felix.bundlerepository/1.6.4/org.apache.felix.bundlerepository-1.6.4.pom";
112 assertTrue( new File( repoStage, mergedArtifactPath ).exists() );
113 assertTrue( new File( repoStage, mergedArtifactPomPath ).exists() );
115 MergeRepositoriesService service = getMergeRepositoriesService( authorizationHeader );
117 service.mergeRepositories( testRepoId + "-stage", testRepoId, true );
119 assertTrue( new File( repo, mergedArtifactPath ).exists() );
120 assertTrue( new File( repo, mergedArtifactPomPath ).exists() );
123 catch ( Exception e )
125 log.error( e.getMessage(), e );
130 deleteTestRepo( testRepoId );