1 package org.apache.archiva.rest.services;
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.rest.api.model.ManagedRepository;
23 import org.apache.archiva.rest.api.services.ManagedRepositoriesService;
24 import org.apache.archiva.rest.api.services.RepositoriesService;
25 import org.apache.cxf.jaxrs.client.ServerWebApplicationException;
26 import org.apache.cxf.jaxrs.client.WebClient;
27 import org.apache.maven.archiva.common.utils.FileUtil;
28 import org.junit.Test;
33 * @author Olivier Lamy
35 public class RepositoriesServiceTest
36 extends AbstractArchivaRestTest
39 @Test( expected = ServerWebApplicationException.class )
40 public void scanRepoKarmaFailed()
43 RepositoriesService service = getRepositoriesService();
46 service.scanRepository( "id", true );
48 catch ( ServerWebApplicationException e )
50 assertEquals( 403, e.getStatus() );
56 public void scanRepo()
59 RepositoriesService service = getRepositoriesService();
60 WebClient.client( service ).header( "Authorization", authorizationHeader );
61 WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 );
63 ManagedRepositoriesService managedRepositoriesService = getManagedRepositoriesService();
64 WebClient.client( managedRepositoriesService ).header( "Authorization", authorizationHeader );
65 WebClient.getConfig( managedRepositoriesService ).getHttpConduit().getClient().setReceiveTimeout( 300000 );
67 String repoId = managedRepositoriesService.getManagedRepositories().get( 0 ).getId();
69 assertTrue( service.scanRepository( repoId, true ) );
71 log.info( "scanRepo call ok " );
73 assertTrue( service.alreadyScanning( repoId ) );
78 protected ManagedRepository getTestManagedRepository()
80 String location = new File( FileUtil.getBasedir(), "target/test-repo" ).getAbsolutePath();
81 return new ManagedRepository( "TEST", "test", location, "default", true, true, false, false, "2 * * * * ?" );