Author: joakime
Date: Tue Feb 27 14:17:45 2007
New Revision: 512448
URL: http://svn.apache.org/viewvc?view=rev&rev=512448
Log:
artifact persistence work
Added:
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/AbstractIbatisStore.java
(with props)
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/artifact/
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/artifact/ArtifactKey.java
(with props)
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/artifact/ArtifactPersistence.java
(with props)
maven/archiva/trunk/archiva-database/src/main/resources/org/apache/maven/archiva/database/ArtifactKey.xml
(with props)
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/AbstractArchivaDatabaseTestCase.java
(with props)
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/artifact/
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/artifact/ArtifactPersistenceTest.java
(with props)
maven/archiva/trunk/archiva-database/src/test/resources/ibatis-config.xml
- copied, changed from r512005,
maven/archiva/trunk/archiva-database/src/main/resources/ibatis-config.xml
Removed:
maven/archiva/trunk/archiva-database/src/main/resources/ibatis-config.xml
Modified:
maven/archiva/trunk/archiva-database/pom.xml
maven/archiva/trunk/archiva-database/src/main/resources/org/apache/maven/archiva/database/ManageTables.xml
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/RepositoryMetadataDatabaseTest.java
Modified: maven/archiva/trunk/archiva-database/pom.xml
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-database/pom.xml?view=diff&rev=512448&r1=512447&r2=512448
==============================================================================
--- maven/archiva/trunk/archiva-database/pom.xml (original)
+++ maven/archiva/trunk/archiva-database/pom.xml Tue Feb 27 14:17:45 2007
@@ -38,7 +38,7 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact-manager</artifactId>
</dependency>
- <dependency>
+ <dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
</dependency>
@@ -71,19 +71,19 @@
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>logkit</groupId>
+ <artifactId>logkit</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
- <version>1.2.7</version>
+ <version>1.2.8</version>
</dependency>
- <!-- TEST DEPS
- <dependency>
- <groupId>hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
- <version>1.7.3.3</version>
- <scope>test</scope>
- </dependency> -->
+ <!-- TEST DEPS -->
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
Added:
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/AbstractIbatisStore.java
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/AbstractIbatisStore.java?view=auto&rev=512448
==============================================================================
---
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/AbstractIbatisStore.java
(added)
+++
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/AbstractIbatisStore.java
Tue Feb 27 14:17:45 2007
@@ -0,0 +1,180 @@
+package org.apache.maven.archiva.database;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.ibatis.sqlmap.client.SqlMapClient;
+
+import org.codehaus.plexus.ibatis.PlexusIbatisHelper;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+/**
+ * AbstractIbatisStore
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public abstract class AbstractIbatisStore
+ extends AbstractLogEnabled
+ implements Initializable
+{
+ /**
+ * @plexus.requirement
+ */
+ protected PlexusIbatisHelper ibatisHelper;
+
+ /**
+ * @plexus.configuration default-value="create"
+ */
+ private String createPrefix;
+
+ /**
+ * @plexus.configuration default-value="drop"
+ */
+ private String dropPrefix;
+
+ protected abstract String[] getTableNames();
+
+ public void initialize()
+ throws InitializationException
+ {
+ try
+ {
+ String tableNames[] = getTableNames();
+ for ( int i = 0; i < tableNames.length; i++ )
+ {
+ String tableName = tableNames[i];
+ initializeTable( tableName );
+ }
+ }
+ catch ( ArchivaDatabaseException e )
+ {
+ throw new InitializationException( "Unable to initialize the
database: " + e.getMessage(), e );
+ }
+ }
+
+ protected void initializeTable( String tableName )
+ throws ArchivaDatabaseException
+ {
+ SqlMapClient sqlMap = ibatisHelper.getSqlMapClient();
+
+ try
+ {
+ sqlMap.startTransaction();
+
+ Connection con = sqlMap.getCurrentConnection();
+
+ DatabaseMetaData databaseMetaData = con.getMetaData();
+
+ ResultSet rs = databaseMetaData.getTables( con.getCatalog(), null,
null, null );
+
+ // check if the index database exists in the database
+ while ( rs.next() )
+ {
+ String dbTableName = rs.getString( "TABLE_NAME" );
+
+ // if it does then we are already initialized
+ if ( dbTableName.toLowerCase().equals( tableName.toLowerCase()
) )
+ {
+ return;
+ }
+ }
+
+ // Create the tables
+
+ getLogger().info( "Creating table: " + tableName );
+ sqlMap.update( createPrefix + tableName, null );
+
+ sqlMap.commitTransaction();
+ }
+ catch ( SQLException e )
+ {
+ getLogger().error( "Error while initializing database, showing all
linked exceptions in SQLException." );
+
+ while ( e != null )
+ {
+ getLogger().error( e.getMessage(), e );
+
+ e = e.getNextException();
+ }
+
+ throw new ArchivaDatabaseException( "Error while setting up
database.", e );
+ }
+ finally
+ {
+ try
+ {
+ sqlMap.endTransaction();
+ }
+ catch ( SQLException e )
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ protected void dropTable( String tableName )
+ throws ArchivaDatabaseException
+ {
+ SqlMapClient sqlMap = ibatisHelper.getSqlMapClient();
+
+ try
+ {
+ sqlMap.startTransaction();
+
+ getLogger().info( "Dropping table: " + tableName );
+ sqlMap.update( dropPrefix + tableName, null );
+
+ sqlMap.commitTransaction();
+ }
+ catch ( SQLException e )
+ {
+ getLogger().error( "Error while dropping database, showing all
linked exceptions in SQLException." );
+
+ while ( e != null )
+ {
+ getLogger().error( e.getMessage(), e );
+
+ e = e.getNextException();
+ }
+
+ throw new ArchivaDatabaseException( "Error while dropping
database.", e );
+ }
+ finally
+ {
+ try
+ {
+ sqlMap.endTransaction();
+ }
+ catch ( SQLException e )
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+
+}
Propchange:
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/AbstractIbatisStore.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/AbstractIbatisStore.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Propchange:
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/AbstractIbatisStore.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/artifact/ArtifactKey.java
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/artifact/ArtifactKey.java?view=auto&rev=512448
==============================================================================
---
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/artifact/ArtifactKey.java
(added)
+++
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/artifact/ArtifactKey.java
Tue Feb 27 14:17:45 2007
@@ -0,0 +1,101 @@
+package org.apache.maven.archiva.database.artifact;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * ArtifactKey
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class ArtifactKey
+{
+ private String groupId;
+
+ private String artifactId;
+
+ private String version;
+
+ private String classifier;
+
+ private String type;
+
+ private long id;
+
+ public String getArtifactId()
+ {
+ return artifactId;
+ }
+
+ public void setArtifactId( String artifactId )
+ {
+ this.artifactId = artifactId;
+ }
+
+ public String getClassifier()
+ {
+ return classifier;
+ }
+
+ public void setClassifier( String classifier )
+ {
+ this.classifier = classifier;
+ }
+
+ public String getGroupId()
+ {
+ return groupId;
+ }
+
+ public void setGroupId( String groupId )
+ {
+ this.groupId = groupId;
+ }
+
+ public long getId()
+ {
+ return id;
+ }
+
+ public void setId( long id )
+ {
+ this.id = id;
+ }
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public void setType( String type )
+ {
+ this.type = type;
+ }
+
+ public String getVersion()
+ {
+ return version;
+ }
+
+ public void setVersion( String version )
+ {
+ this.version = version;
+ }
+}
Propchange:
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/artifact/ArtifactKey.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/artifact/ArtifactKey.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Propchange:
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/artifact/ArtifactKey.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/artifact/ArtifactPersistence.java
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/artifact/ArtifactPersistence.java?view=auto&rev=512448
==============================================================================
---
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/artifact/ArtifactPersistence.java
(added)
+++
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/artifact/ArtifactPersistence.java
Tue Feb 27 14:17:45 2007
@@ -0,0 +1,135 @@
+package org.apache.maven.archiva.database.artifact;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.ibatis.sqlmap.client.SqlMapClient;
+
+import org.apache.maven.archiva.database.AbstractIbatisStore;
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
+import org.apache.maven.artifact.Artifact;
+
+import java.sql.SQLException;
+
+/**
+ * ArtifactPersistence
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Joakim Erdfelt</a>
+ * @version $Id$
+ *
+ * @plexus.component
role="org.apache.maven.archiva.database.artifact.ArtifactPersistence"
+ */
+public class ArtifactPersistence
+ extends AbstractIbatisStore
+{
+ protected String[] getTableNames()
+ {
+ return new String[] { "ArtifactKeys" };
+ }
+
+ private ArtifactKey toKey(Artifact artifact)
+ {
+ ArtifactKey key = new ArtifactKey();
+ key.setGroupId( artifact.getGroupId() );
+ key.setArtifactId( artifact.getArtifactId() );
+ key.set
+ return key;
+ }
+
+ public void create( Artifact artifact ) throws ArchivaDatabaseException
+ {
+ SqlMapClient sqlMap = ibatisHelper.getSqlMapClient();
+
+ try
+ {
+ sqlMap.startTransaction();
+
+ getLogger().info( "Adding artifact." );
+ sqlMap.update( "addArtifact", artifact );
+
+
+ sqlMap.commitTransaction();
+ }
+ catch ( SQLException e )
+ {
+ getLogger().error( "Error while executing statement, showing all
linked exceptions in SQLException." );
+
+ while ( e != null )
+ {
+ getLogger().error( e.getMessage(), e );
+
+ e = e.getNextException();
+ }
+
+ throw new ArchivaDatabaseException( "Error while executing
statement.", e );
+ }
+ finally
+ {
+ try
+ {
+ sqlMap.endTransaction();
+ }
+ catch ( SQLException e )
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public Artifact read( String groupId, String artifactId, String version )
+ {
+ return null;
+ }
+
+ public Artifact read( String groupId, String artifactId, String version,
String type )
+ {
+ return null;
+ }
+
+ public Artifact read( String groupId, String artifactId, String version,
String classifier, String type )
+ {
+ return null;
+ }
+
+ public void update( Artifact artifact )
+ {
+
+ }
+
+ public void delete( Artifact artifact )
+ {
+
+ }
+
+ public void delete( String groupId, String artifactId, String version )
+ {
+
+ }
+
+ public void delete( String groupId, String artifactId, String version,
String type )
+ {
+
+ }
+
+ public void delete( String groupId, String artifactId, String version,
String classifier, String type )
+ {
+
+ }
+
+}
Propchange:
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/artifact/ArtifactPersistence.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/artifact/ArtifactPersistence.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Propchange:
maven/archiva/trunk/archiva-database/src/main/java/org/apache/maven/archiva/database/artifact/ArtifactPersistence.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
maven/archiva/trunk/archiva-database/src/main/resources/org/apache/maven/archiva/database/ArtifactKey.xml
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-database/src/main/resources/org/apache/maven/archiva/database/ArtifactKey.xml?view=auto&rev=512448
==============================================================================
---
maven/archiva/trunk/archiva-database/src/main/resources/org/apache/maven/archiva/database/ArtifactKey.xml
(added)
+++
maven/archiva/trunk/archiva-database/src/main/resources/org/apache/maven/archiva/database/ArtifactKey.xml
Tue Feb 27 14:17:45 2007
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
+"http://ibatis.apache.org/dtd/sql-map-2.dtd">
+
+<sqlMap namespace="ArtifactKey">
+
+<select id="getArtifactKey"
resultClass="org.apache.maven.archiva.database.artifact.ArtifactKey">
+ SELECT
+ ARTIFACT_KEY as id
+ GROUP_ID as groupId,
+ ARTIFACT_ID as artifactId,
+ VERSION as version,
+ CLASSIFER as classifier,
+ TYPE as type,
+ FROM ARTIFACT_KEYS
+ WHERE ARTIFACT_KEY = #value#
+</select>
+
+<insert id="addArtifactKey"
parameterClass="org.apache.maven.archiva.database.artifact.ArtifactKey">
+ INSERT INTO
+ ARTIFACT_KEYS ( GROUP_ID, ARTIFACT_ID, VERSION_ID, CLASSIFIER, TYPE )
+ VALUES (#groupId#, #artifactId#, #version# )
+</insert>
+
+</sqlMap>
\ No newline at end of file
Propchange:
maven/archiva/trunk/archiva-database/src/main/resources/org/apache/maven/archiva/database/ArtifactKey.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/archiva/trunk/archiva-database/src/main/resources/org/apache/maven/archiva/database/ArtifactKey.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Propchange:
maven/archiva/trunk/archiva-database/src/main/resources/org/apache/maven/archiva/database/ArtifactKey.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified:
maven/archiva/trunk/archiva-database/src/main/resources/org/apache/maven/archiva/database/ManageTables.xml
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-database/src/main/resources/org/apache/maven/archiva/database/ManageTables.xml?view=diff&rev=512448&r1=512447&r2=512448
==============================================================================
---
maven/archiva/trunk/archiva-database/src/main/resources/org/apache/maven/archiva/database/ManageTables.xml
(original)
+++
maven/archiva/trunk/archiva-database/src/main/resources/org/apache/maven/archiva/database/ManageTables.xml
Tue Feb 27 14:17:45 2007
@@ -5,10 +5,33 @@
<sqlMap namespace="CreateTables">
+<!-- .\ ARTIFACT
\.________________________________________________________________________________________
-->
+
+<statement id="createArtifactKeys">
+ CREATE TABLE ArtifactKeys (
+ GROUP_ID varchar (100) not null,
+ ARTIFACT_ID varchar (100) not null,
+ VERSION varchar (50) not null,
+ CLASSIFIER varchar (50),
+ TYPE varchar (20),
+ ARTIFACT_KEY integer generated always as identity ( start with 1 ),
+ primary key ( GROUP_ID, ARTIFACT_ID, VERSION, CLASSIFIER, TYPE )
+ )
+</statement>
+
+<statement id="dropArtifactKeys">
+ DROP TABLE ArtifactKeys
+</statement>
+
+
+<!-- .\ METADATA
\.________________________________________________________________________________________
-->
+
<!--
METADATA_KEYS is the index table for all other tables
need to make the lookup on this table fast, perhaps by indexing the
combination of g:a:v in a lookup column
+
+TODO: Ensure that there is never a duplicate of the multi-part complex key
(groupId, artifactId, version)
-->
<statement id="createMetadataKeys">
CREATE TABLE MetadataKeys (
Added:
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/AbstractArchivaDatabaseTestCase.java
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/AbstractArchivaDatabaseTestCase.java?view=auto&rev=512448
==============================================================================
---
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/AbstractArchivaDatabaseTestCase.java
(added)
+++
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/AbstractArchivaDatabaseTestCase.java
Tue Feb 27 14:17:45 2007
@@ -0,0 +1,47 @@
+package org.apache.maven.archiva.database;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.util.FileUtils;
+
+import java.io.File;
+
+/**
+ * AbstractArchivaDatabaseTestCase
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class AbstractArchivaDatabaseTestCase
+ extends PlexusTestCase
+{
+ protected void setUp()
+ throws Exception
+ {
+ File derbyDbDir = new File( "target/plexus-home/testdb" );
+ if ( derbyDbDir.exists() )
+ {
+ FileUtils.deleteDirectory( derbyDbDir );
+ }
+
+ super.setUp();
+ }
+}
Propchange:
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/AbstractArchivaDatabaseTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/AbstractArchivaDatabaseTestCase.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Propchange:
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/AbstractArchivaDatabaseTestCase.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified:
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/RepositoryMetadataDatabaseTest.java
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/RepositoryMetadataDatabaseTest.java?view=diff&rev=512448&r1=512447&r2=512448
==============================================================================
---
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/RepositoryMetadataDatabaseTest.java
(original)
+++
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/RepositoryMetadataDatabaseTest.java
Tue Feb 27 14:17:45 2007
@@ -1,10 +1,35 @@
package org.apache.maven.archiva.database;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
import org.apache.maven.archiva.database.key.MetadataKey;
import org.apache.maven.artifact.repository.metadata.Metadata;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.ibatis.PlexusIbatisHelper;
+/**
+ * RepositoryMetadataDatabaseTest
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Joakim Erdfelt</a>
+ * @version $Id$
+ */
public class RepositoryMetadataDatabaseTest
extends PlexusTestCase
{
@@ -16,7 +41,6 @@
protected void setUp()
throws Exception
{
- // TODO Auto-generated method stub
super.setUp();
}
Added:
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/artifact/ArtifactPersistenceTest.java
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/artifact/ArtifactPersistenceTest.java?view=auto&rev=512448
==============================================================================
---
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/artifact/ArtifactPersistenceTest.java
(added)
+++
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/artifact/ArtifactPersistenceTest.java
Tue Feb 27 14:17:45 2007
@@ -0,0 +1,70 @@
+package org.apache.maven.archiva.database.artifact;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase;
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+
+/**
+ * ArtifactPersistenceTest
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class ArtifactPersistenceTest
+ extends AbstractArchivaDatabaseTestCase
+{
+ private ArtifactFactory artifactFactory;
+
+ private ArtifactPersistence db;
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
+ db = (ArtifactPersistence) lookup( ArtifactPersistence.class.getName()
);
+ }
+
+ public void testLookup()
+ {
+ assertNotNull( db );
+ }
+
+ public void testAddArtifact() throws ArchivaDatabaseException
+ {
+ String groupId = "org.apache.maven.archiva";
+ String artifactId = "archiva-test-artifact";
+ String version = "1.0";
+
+ Artifact artifact = artifactFactory
+ .createArtifact( groupId, artifactId, version,
Artifact.SCOPE_COMPILE, "jar" );
+
+ db.create( artifact );
+
+ Artifact fetched = db.read( groupId, artifactId, version );
+
+ assertNotNull( "Should have fetched an Artifact.", fetched );
+ assertEquals( "Should have fetched the expected Artifact.", artifact,
fetched );
+ }
+}
Propchange:
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/artifact/ArtifactPersistenceTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/artifact/ArtifactPersistenceTest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Propchange:
maven/archiva/trunk/archiva-database/src/test/java/org/apache/maven/archiva/database/artifact/ArtifactPersistenceTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied:
maven/archiva/trunk/archiva-database/src/test/resources/ibatis-config.xml (from
r512005,
maven/archiva/trunk/archiva-database/src/main/resources/ibatis-config.xml)
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-database/src/test/resources/ibatis-config.xml?view=diff&rev=512448&p1=maven/archiva/trunk/archiva-database/src/main/resources/ibatis-config.xml&r1=512005&p2=maven/archiva/trunk/archiva-database/src/test/resources/ibatis-config.xml&r2=512448
==============================================================================
--- maven/archiva/trunk/archiva-database/src/main/resources/ibatis-config.xml
(original)
+++ maven/archiva/trunk/archiva-database/src/test/resources/ibatis-config.xml
Tue Feb 27 14:17:45 2007
@@ -23,6 +23,15 @@
</dataSource>
</transactionManager>
- <sqlMap resource="org/apache/maven/archiva/database/CreateDatabases.xml"/>
+ <!--
+ <resultObjectFactory
type="org.codehaus.plexus.ibatis.PlexusResultObjectFactory" >
+ <property name="foo" value="bar"/>
+ </resultObjectFactory>
+ -->
+
+ <sqlMap resource="org/apache/maven/archiva/database/ManageTables.xml"/>
<sqlMap resource="org/apache/maven/archiva/database/MetadataKey.xml"/>
+ <sqlMap resource="org/apache/maven/archiva/database/ArtifactKey.xml"/>
+ <sqlMap resource="org/apache/maven/archiva/database/RepositoryMetadata.xml"/>
+
</sqlMapConfig>