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.model.ArchivaArtifact;
29 import org.apache.maven.archiva.model.ArchivaArtifactModel;
30 import org.apache.maven.archiva.model.ArchivaProjectModel;
35 * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
37 public abstract class AbstractDatabaseCleanupTest
38 extends PlexusTestCase
40 ArchivaConfiguration archivaConfig;
42 RepositoryContentFactory repositoryFactory;
44 public static final String TEST_GROUP_ID = "org.apache.maven.archiva";
46 public static final String TEST_ARTIFACT_ID = "cleanup-artifact-test";
48 public static final String TEST_VERSION = "1.0";
50 public static final String TEST_REPO_ID = "test-repo";
57 // archiva configuration (need to update the repository url)
58 File userFile = getTestFile( "target/test/repository-manager.xml" );
60 assertFalse( userFile.exists() );
62 userFile.getParentFile().mkdirs();
63 FileUtils.copyFileToDirectory( getTestFile( "src/test/conf/repository-manager.xml" ),
64 userFile.getParentFile() );
66 archivaConfig = (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "database-cleanup" );
68 Configuration configuration = archivaConfig.getConfiguration();
69 ManagedRepositoryConfiguration repo = configuration.findManagedRepositoryById( TEST_REPO_ID );
70 repo.setLocation( new File( getBasedir(), "src/test/resources/test-repo" ).toString() );
72 archivaConfig.save( configuration );
74 repositoryFactory = (RepositoryContentFactory) lookup( RepositoryContentFactory.class );
77 protected ArchivaArtifact createArtifact( String groupId, String artifactId, String version, String type )
79 ArchivaArtifactModel model = new ArchivaArtifactModel();
80 model.setGroupId( groupId );
81 model.setArtifactId( artifactId );
82 model.setVersion( version );
83 model.setType( type );
84 model.setRepositoryId( TEST_REPO_ID );
86 return new ArchivaArtifact( model );
89 protected ArchivaProjectModel createProjectModel( String groupId, String artifactId, String version )
91 ArchivaProjectModel projectModel = new ArchivaProjectModel();
92 projectModel.setGroupId( groupId );
93 projectModel.setArtifactId( artifactId );
94 projectModel.setVersion( version );