1 package org.apache.maven.archiva.consumers.database;
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.codehaus.plexus.PlexusTestCase;
23 import org.codehaus.plexus.util.FileUtils;
24 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
25 import org.apache.maven.archiva.configuration.Configuration;
26 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
27 import org.apache.maven.archiva.repository.RepositoryContentFactory;
28 import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory;
29 import org.apache.maven.archiva.model.ArchivaArtifact;
30 import org.apache.maven.archiva.model.ArchivaArtifactModel;
31 import org.apache.maven.archiva.model.ArchivaProjectModel;
36 * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
38 public class AbstractDatabaseCleanupTest
39 extends PlexusTestCase
41 ArchivaConfiguration archivaConfig;
43 BidirectionalRepositoryLayoutFactory layoutFactory;
45 RepositoryContentFactory repositoryFactory;
47 public static final String TEST_GROUP_ID = "org.apache.maven.archiva";
49 public static final String TEST_ARTIFACT_ID = "cleanup-artifact-test";
51 public static final String TEST_VERSION = "1.0";
53 public static final String TEST_REPO_ID = "test-repo";
60 // archiva configuration (need to update the repository url)
61 File userFile = getTestFile( "target/test/repository-manager.xml" );
63 assertFalse( userFile.exists() );
65 userFile.getParentFile().mkdirs();
66 FileUtils.copyFileToDirectory( getTestFile( "src/test/conf/repository-manager.xml" ),
67 userFile.getParentFile() );
69 archivaConfig = (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "database-cleanup" );
71 Configuration configuration = archivaConfig.getConfiguration();
72 ManagedRepositoryConfiguration repo = configuration.findManagedRepositoryById( TEST_REPO_ID );
73 repo.setLocation( new File( getBasedir(), "src/test/resources/test-repo" ).toString() );
75 archivaConfig.save( configuration );
77 // set bidirectional repository layout factory
78 layoutFactory = (BidirectionalRepositoryLayoutFactory) lookup( BidirectionalRepositoryLayoutFactory.class );
80 repositoryFactory = (RepositoryContentFactory) lookup( RepositoryContentFactory.class );
83 protected ArchivaArtifact createArtifact( String groupId, String artifactId, String version, String type )
85 ArchivaArtifactModel model = new ArchivaArtifactModel();
86 model.setGroupId( groupId );
87 model.setArtifactId( artifactId );
88 model.setVersion( version );
89 model.setType( type );
90 model.setRepositoryId( TEST_REPO_ID );
92 return new ArchivaArtifact( model );
95 protected ArchivaProjectModel createProjectModel( String groupId, String artifactId, String version )
97 ArchivaProjectModel projectModel = new ArchivaProjectModel();
98 projectModel.setGroupId( groupId );
99 projectModel.setArtifactId( artifactId );
100 projectModel.setVersion( version );