aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-database
diff options
context:
space:
mode:
authorJoakim Erdfelt <joakime@apache.org>2007-05-21 23:01:36 +0000
committerJoakim Erdfelt <joakime@apache.org>2007-05-21 23:01:36 +0000
commitec549451bb1e3c36ec4299d9925378c69ed3b654 (patch)
treefaf9ade9c997bbf2690c5f473317cb234f869690 /archiva-database
parent72be8679efca2a1d5d824d915ae401b13a98af12 (diff)
downloadarchiva-ec549451bb1e3c36ec4299d9925378c69ed3b654.tar.gz
archiva-ec549451bb1e3c36ec4299d9925378c69ed3b654.zip
[MRM-346]: Show Artifact results in error 500.
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@540343 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-database')
-rwxr-xr-xarchiva-database/pom.xml5
-rw-r--r--archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoAccess.java25
-rw-r--r--archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoProjectModelDAOTest.java33
-rw-r--r--archiva-database/src/test/resources/projects/maven-shared-jar-1.0-SNAPSHOT.pom175
4 files changed, 238 insertions, 0 deletions
diff --git a/archiva-database/pom.xml b/archiva-database/pom.xml
index 94811fd12..1f00cff80 100755
--- a/archiva-database/pom.xml
+++ b/archiva-database/pom.xml
@@ -104,6 +104,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.apache.maven.archiva</groupId>
+ <artifactId>archiva-repository-layer</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>test</scope>
diff --git a/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoAccess.java b/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoAccess.java
index 09348d099..4a3938f1d 100644
--- a/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoAccess.java
+++ b/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoAccess.java
@@ -28,10 +28,16 @@ import org.apache.maven.archiva.database.SimpleConstraint;
import org.apache.maven.archiva.database.constraints.AbstractSimpleConstraint;
import org.apache.maven.archiva.model.CompoundKey;
import org.codehaus.plexus.jdo.JdoFactory;
+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 org.jpox.SchemaTool;
+import sun.security.action.GetLongAction;
+
+import java.io.File;
import java.io.PrintStream;
+import java.net.URL;
import java.util.ArrayList;
import java.util.List;
@@ -59,6 +65,7 @@ import javax.jdo.spi.PersistenceCapable;
* @plexus.component role="org.apache.maven.archiva.database.jdo.JdoAccess" role-hint="archiva"
*/
public class JdoAccess
+ extends AbstractLogEnabled
implements Initializable, InstanceLifecycleListener, StoreLifecycleListener
{
/**
@@ -72,7 +79,25 @@ public class JdoAccess
throws InitializationException
{
pmf = jdoFactory.getPersistenceManagerFactory();
+
+ // Create the schema (if needed)
+ URL jdoFileUrls[] = new URL[] { getClass().getResource( "/org/apache/maven/archiva/model/package.jdo" ) };
+
+ File propsFile = null; // intentional
+ boolean verbose = true;
+
+ try
+ {
+ SchemaTool.createSchemaTables( jdoFileUrls, new URL[] {}, propsFile, verbose, null );
+ }
+ catch ( Exception e )
+ {
+ getLogger().error( "Unable to create schema: " + e.getMessage(), e );
+ }
+
+ pmf.getPersistenceManager();
+ // Add the lifecycle listener.
pmf.addInstanceLifecycleListener( this, null );
}
diff --git a/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoProjectModelDAOTest.java b/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoProjectModelDAOTest.java
index edb13129d..ecffd79e1 100644
--- a/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoProjectModelDAOTest.java
+++ b/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoProjectModelDAOTest.java
@@ -23,7 +23,9 @@ import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase;
import org.apache.maven.archiva.database.ProjectModelDAO;
import org.apache.maven.archiva.model.ArchivaProjectModel;
import org.apache.maven.archiva.model.jpox.ArchivaProjectModelKey;
+import org.apache.maven.archiva.repository.project.ProjectModelReader;
+import java.io.File;
import java.util.Date;
import java.util.List;
@@ -108,4 +110,35 @@ public class JdoProjectModelDAOTest
projectDao.deleteProjectModel( actualModel );
assertEquals( 0, projectDao.queryProjectModels( null ).size() );
}
+
+ public void testSaveGetRealProjectModel()
+ throws Exception
+ {
+ String groupId = "org.apache.maven.shared";
+ String artifactId = "maven-shared-jar";
+ String version = "1.0-SNAPSHOT";
+
+ ProjectModelDAO projectDao = dao.getProjectModelDAO();
+
+ ProjectModelReader modelReader = (ProjectModelReader) lookup( ProjectModelReader.class, "model400" );
+
+ File pomFile = getTestFile( "src/test/resources/projects/maven-shared-jar-1.0-SNAPSHOT.pom" );
+
+ assertTrue( "pom file should exist: " + pomFile.getAbsolutePath(), pomFile.exists() && pomFile.isFile() );
+
+ ArchivaProjectModel model = modelReader.read( pomFile );
+ assertNotNull( "Model should not be null.", model );
+
+ // Fill in missing (mandatory) fields
+ model.setGroupId( groupId );
+ model.setOrigin( "testcase" );
+
+ projectDao.saveProjectModel( model );
+
+ ArchivaProjectModel savedModel = projectDao.getProjectModel( groupId, artifactId, version );
+ assertNotNull( "Project model should not be null.", savedModel );
+
+ // Test proper detachment of sub-objects.
+ assertNotNull( "model.parent != null", savedModel.getParentProject() );
+ }
}
diff --git a/archiva-database/src/test/resources/projects/maven-shared-jar-1.0-SNAPSHOT.pom b/archiva-database/src/test/resources/projects/maven-shared-jar-1.0-SNAPSHOT.pom
new file mode 100644
index 000000000..9234995b7
--- /dev/null
+++ b/archiva-database/src/test/resources/projects/maven-shared-jar-1.0-SNAPSHOT.pom
@@ -0,0 +1,175 @@
+<?xml version="1.0" ?>
+
+<!--
+ ~ Copyright 2005-2006 The Apache Software Foundation.
+ ~
+ ~ Licensed 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.
+ -->
+
+<project
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-shared-components</artifactId>
+ <version>3</version>
+ </parent>
+
+ <artifactId>maven-shared-jar</artifactId>
+ <packaging>jar</packaging>
+ <version>1.0-SNAPSHOT</version>
+
+ <name>Maven Shared Jar Utils</name>
+
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/maven/sandbox/maven-shared-jar</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/maven/sandbox/maven-shared-jar</developerConnection>
+ <url>http://svn.apache.org/viewcvs.cgi/maven/sandbox/maven-shared-jar</url>
+ </scm>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>descriptor</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>clean</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>changelog-maven-plugin</artifactId>
+ <!-- Changelog has been moved to org.apache.maven.plugins
+ Need to adjust this location in the future to point to
+ the finalized copy of this plugin.
+ <artifactId>maven-changelog-plugin</artifactId>
+ -->
+ </plugin>
+ <plugin>
+ <artifactId>maven-jxr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <configuration>
+ <linkXref>true</linkXref>
+ <rulesets>
+ <ruleset>rulesets/basic.xml</ruleset>
+ <ruleset>rulesets/codesize.xml</ruleset>
+ <ruleset>rulesets/controversial.xml</ruleset>
+ <ruleset>rulesets/coupling.xml</ruleset>
+ <ruleset>rulesets/finalizers.xml</ruleset>
+ <ruleset>rulesets/imports.xml</ruleset>
+ <ruleset>rulesets/junit.xml</ruleset>
+ <ruleset>rulesets/logging-jakarta-commons.xml</ruleset>
+ <ruleset>rulesets/naming.xml</ruleset>
+ <ruleset>rulesets/optimizations.xml</ruleset>
+ <ruleset>rulesets/strictexception.xml</ruleset>
+ <ruleset>rulesets/strings.xml</ruleset>
+ <ruleset>rulesets/sunsecure.xml</ruleset>
+ <ruleset>rulesets/unusedcode.xml</ruleset>
+ </rulesets>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <repositories>
+ <repository>
+ <id>snapshots.codehaus</id>
+ <url>http://snapshots.repository.codehaus.org/</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-model</artifactId>
+ <version>2.0.2</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact-manager</artifactId>
+ <version>2.0.2</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-digest</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.bcel</groupId>
+ <artifactId>bcel</artifactId>
+ <version>5.2</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.1</version>
+ <scope>compile</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>