1 package org.apache.maven.archiva.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.apache.maven.archiva.database.key.MetadataKey;
23 import org.apache.maven.artifact.repository.metadata.Metadata;
24 import org.codehaus.plexus.PlexusTestCase;
25 import org.codehaus.plexus.ibatis.PlexusIbatisHelper;
28 * RepositoryMetadataDatabaseTest
30 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
33 public class RepositoryMetadataDatabaseTest
34 extends PlexusTestCase
39 protected PlexusIbatisHelper ibatisHelper;
41 protected void setUp()
47 public void testRepositoryMetadataCreationAndDeletion() throws Exception
49 RepositoryMetadataDatabase db = (RepositoryMetadataDatabase) lookup( "org.apache.maven.archiva.database.RepositoryMetadataDatabase", "default" );
52 assertTrue( db.tableExists( "RepositoryMetadata" ) );
53 assertTrue( db.tableExists( "MetadataKeys" ) );
55 db.dropTable( "RepositoryMetadata" );
56 db.dropTable( "MetadataKeys" );
58 assertFalse( db.tableExists( "RepositoryMetadata" ) );
59 assertFalse( db.tableExists( "MetadataKeys" ) );
62 public void testMetadataKeyRetrieval() throws Exception
64 RepositoryMetadataDatabase db = (RepositoryMetadataDatabase) lookup( "org.apache.maven.archiva.database.RepositoryMetadataDatabase", "default" );
66 Metadata metadata = new Metadata();
67 metadata.setArtifactId( "testArtifactId" );
68 metadata.setGroupId( "testGroupId" );
69 metadata.setVersion( "testVersion" );
71 MetadataKey metadataKey = db.getMetadataKey( metadata );
73 assertTrue( metadataKey.getMetadataKey() > 0 );
74 assertEquals( metadataKey.getArtifactId(), metadata.getArtifactId() );
75 assertEquals( metadataKey.getGroupId(), metadata.getGroupId() );
76 assertEquals( metadataKey.getVersion(), metadata.getVersion() );
78 db.dropTable( "RepositoryMetadata" );
79 db.dropTable( "MetadataKeys" );
81 assertFalse( db.tableExists( "RepositoryMetadata" ) );
82 assertFalse( db.tableExists( "MetadataKeys" ) );