1 package org.apache.archiva.admin.repository.remote;
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.admin.repository.AbstractRepositoryAdminTest;
22 import org.junit.Test;
24 import javax.inject.Inject;
25 import java.util.List;
28 * @author Olivier Lamy
30 public class RemoteRepositoryAdminTest
31 extends AbstractRepositoryAdminTest
35 private RemoteRepositoryAdmin remoteRepositoryAdmin;
41 List<RemoteRepository> remoteRepositories = remoteRepositoryAdmin.getRemoteRepositories();
42 assertNotNull( remoteRepositories );
43 assertTrue( remoteRepositories.size() > 0 );
44 log.info( "remote " + remoteRepositories );
51 RemoteRepository central = remoteRepositoryAdmin.getRemoteRepository( "central" );
52 assertNotNull( central );
53 assertEquals( "http://repo1.maven.org/maven2", central.getUrl() );
54 assertEquals( 60, central.getTimeout() );
55 assertNull( central.getUserName() );
56 assertNull( central.getPassword() );
60 public void addAndDelete()
63 int initialSize = remoteRepositoryAdmin.getRemoteRepositories().size();
65 RemoteRepository remoteRepository = getRemoteRepository();
67 remoteRepositoryAdmin.addRemoteRepository( remoteRepository );
69 assertEquals( initialSize + 1, remoteRepositoryAdmin.getRemoteRepositories().size() );
71 RemoteRepository repo = remoteRepositoryAdmin.getRemoteRepository( "foo" );
72 assertNotNull( repo );
73 assertEquals( getRemoteRepository().getPassword(), repo.getPassword() );
74 assertEquals( getRemoteRepository().getUrl(), repo.getUrl() );
75 assertEquals( getRemoteRepository().getUserName(), repo.getUserName() );
76 assertEquals( getRemoteRepository().getName(), repo.getName() );
77 assertEquals( getRemoteRepository().getTimeout(), repo.getTimeout() );
79 remoteRepositoryAdmin.deleteRemoteRepository( "foo" );
81 assertEquals( initialSize, remoteRepositoryAdmin.getRemoteRepositories().size() );
83 repo = remoteRepositoryAdmin.getRemoteRepository( "foo" );
88 private RemoteRepository getRemoteRepository()
90 RemoteRepository remoteRepository = new RemoteRepository();
91 remoteRepository.setUrl( "http://foo.com/maven-it-rocks" );
92 remoteRepository.setTimeout( 10 );
93 remoteRepository.setName( "maven foo" );
94 remoteRepository.setUserName( "foo-name" );
95 remoteRepository.setPassword( "toto" );
96 remoteRepository.setId( "foo" );
97 return remoteRepository;