View Javadoc

1   package org.apache.maven.archiva.repository;
2   
3   /*
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
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
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
19   * under the License.
20   */
21  
22  import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
23  import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
24  import org.codehaus.plexus.spring.PlexusInSpringTestCase;
25  
26  import java.io.File;
27  
28  /**
29   * AbstractRepositoryLayerTestCase
30   *
31   * @version $Id: AbstractRepositoryLayerTestCase.java 718864 2008-11-19 06:33:35Z brett $
32   */
33  public abstract class AbstractRepositoryLayerTestCase
34      extends PlexusInSpringTestCase
35  {
36      /**
37       * {@inheritDoc}
38       * @see org.codehaus.plexus.spring.PlexusInSpringTestCase#getSpringConfigLocation()
39       */
40      @Override
41      protected String getSpringConfigLocation()
42      {
43          return "org/apache/maven/archiva/repository/spring-context.xml";
44      }
45  
46      protected ManagedRepositoryConfiguration createRepository( String id, String name, File location )
47      {
48          ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
49          repo.setId( id );
50          repo.setName( name );
51          repo.setLocation( location.getAbsolutePath() );
52          return repo;
53      }
54  
55      protected RemoteRepositoryConfiguration createRemoteRepository( String id, String name, String url )
56      {
57          RemoteRepositoryConfiguration repo = new RemoteRepositoryConfiguration();
58          repo.setId( id );
59          repo.setName( name );
60          repo.setUrl( url );
61          return repo;
62      }
63  
64      protected ManagedRepositoryContent createManagedRepositoryContent( String id, String name, File location, String layout )
65          throws Exception
66      {
67          ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
68          repo.setId( id );
69          repo.setName( name );
70          repo.setLocation( location.getAbsolutePath() );
71          repo.setLayout( layout );
72  
73          ManagedRepositoryContent repoContent = (ManagedRepositoryContent) lookup( ManagedRepositoryContent.class, layout );
74          repoContent.setRepository( repo );
75  
76          return repoContent;
77      }
78  
79      protected RemoteRepositoryContent createRemoteRepositoryContent( String id, String name, String url, String layout )
80          throws Exception
81      {
82          RemoteRepositoryConfiguration repo = new RemoteRepositoryConfiguration();
83          repo.setId( id );
84          repo.setName( name );
85          repo.setUrl( url );
86          repo.setLayout( layout );
87  
88          RemoteRepositoryContent repoContent = (RemoteRepositoryContent) lookup( RemoteRepositoryContent.class, layout );
89          repoContent.setRepository( repo );
90  
91          return repoContent;
92      }
93  }