aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules
diff options
context:
space:
mode:
authorBrett Porter <brett@apache.org>2009-12-08 23:20:34 +0000
committerBrett Porter <brett@apache.org>2009-12-08 23:20:34 +0000
commitadd8678ac572937ad7d89f0042ec0aad1a47b724 (patch)
tree3df14e2d531b8db33405b6a2dbbceb33126425ee /archiva-modules
parent4ea422a9d19e45394f442df2b6468d7aa5be8482 (diff)
downloadarchiva-add8678ac572937ad7d89f0042ec0aad1a47b724.tar.gz
archiva-add8678ac572937ad7d89f0042ec0aad1a47b724.zip
[MRM-1025] remove more now unused database code
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@888625 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules')
-rw-r--r--archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java9
-rw-r--r--archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArchivaRepositoryByUrlConstraint.java49
-rw-r--r--archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsProcessedConstraint.java59
-rw-r--r--archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RecentArtifactsByAgeConstraint.java60
-rw-r--r--archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraint.java124
-rw-r--r--archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueGroupIdConstraint.java100
-rw-r--r--archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java6
-rw-r--r--archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/AllTests.java2
-rw-r--r--archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RecentArtifactsByAgeConstraintTest.java104
-rw-r--r--archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraintTest.java158
-rw-r--r--archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueGroupIdConstraintTest.java310
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/ArchivaDAOStub.java30
12 files changed, 0 insertions, 1011 deletions
diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java
index 99eb039d3..92983e955 100644
--- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java
+++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java
@@ -19,7 +19,6 @@ package org.apache.maven.archiva.database;
* under the License.
*/
-import java.io.Serializable;
import java.util.List;
/**
@@ -39,14 +38,6 @@ public interface ArchivaDAO
*/
List<?> query( SimpleConstraint constraint );
- /**
- * Perform a simple save of a peristable object to the database.
- *
- * @param o the serializable (persistable) object to save.
- * @return the post-serialized object.
- */
- Object save( Serializable obj );
-
ArtifactDAO getArtifactDAO();
RepositoryProblemDAO getRepositoryProblemDAO();
diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArchivaRepositoryByUrlConstraint.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArchivaRepositoryByUrlConstraint.java
deleted file mode 100644
index e584dab20..000000000
--- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArchivaRepositoryByUrlConstraint.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.apache.maven.archiva.database.constraints;
-
-/*
- * 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.Constraint;
-
-/**
- * ArchivaRepositoryByUrlConstraint
- *
- * @version $Id$
- */
-public class ArchivaRepositoryByUrlConstraint
- extends AbstractDeclarativeConstraint
- implements Constraint
-{
- private String whereCondition;
-
- public ArchivaRepositoryByUrlConstraint( String url )
- {
- whereCondition = "this.url == '" + url + "'";
- }
-
- public String getWhereCondition()
- {
- return whereCondition;
- }
-
- public String getSortColumn()
- {
- return "url";
- }
-}
diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsProcessedConstraint.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsProcessedConstraint.java
deleted file mode 100644
index 324964c15..000000000
--- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsProcessedConstraint.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package org.apache.maven.archiva.database.constraints;
-
-/*
- * 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 java.util.Date;
-
-import org.apache.maven.archiva.database.Constraint;
-
-/**
- * ArtifactsProcessedConstraint
- *
- * @version $Id$
- */
-public class ArtifactsProcessedConstraint
- extends AbstractDeclarativeConstraint
- implements Constraint
-{
- private String whereClause;
-
- /**
- * A Constraint showing artifacts processed since date provided.
- * @param since
- */
- public ArtifactsProcessedConstraint( Date since )
- {
- whereClause = "whenProcessed > since";
- declImports = new String[] { "import java.util.Date" };
- declParams = new String[] { "Date since" };
- params = new Object[] { since };
- }
-
- public String getSortColumn()
- {
- return "groupId";
- }
-
- public String getWhereCondition()
- {
- return whereClause;
- }
-
-}
diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RecentArtifactsByAgeConstraint.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RecentArtifactsByAgeConstraint.java
deleted file mode 100644
index ad505da14..000000000
--- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RecentArtifactsByAgeConstraint.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.apache.maven.archiva.database.constraints;
-
-/*
- * 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.Constraint;
-
-import java.util.Calendar;
-import java.util.Date;
-
-/**
- * Constraint for artifacts that are of a certain age (in days) or newer.
- *
- * @version $Id$
- */
-public class RecentArtifactsByAgeConstraint
- extends AbstractDeclarativeConstraint
- implements Constraint
-{
- private String whereClause;
-
- public RecentArtifactsByAgeConstraint( int daysOld )
- {
- Calendar cal = Calendar.getInstance();
- // Extra subtraction of 1 done to allow for lastModified that occur on the day represented by 'daysOld'.
- cal.add( Calendar.DAY_OF_MONTH, (( -1 ) * daysOld) - 1 );
- Date cutoffDate = cal.getTime();
-
- whereClause = "this.lastModified >= cutoffDate";
- declImports = new String[] { "import java.util.Date" };
- declParams = new String[] { "java.util.Date cutoffDate" };
- params = new Object[] { cutoffDate };
- }
-
- public String getSortColumn()
- {
- return "groupId";
- }
-
- public String getWhereCondition()
- {
- return whereClause;
- }
-}
diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraint.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraint.java
deleted file mode 100644
index 1449352af..000000000
--- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraint.java
+++ /dev/null
@@ -1,124 +0,0 @@
-package org.apache.maven.archiva.database.constraints;
-
-/*
- * 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.Constraint;
-import org.apache.maven.archiva.model.ArchivaArtifactModel;
-
-import java.util.List;
-
-/**
- * Obtain a set of unique ArtifactIds for the specified groupId.
- *
- * @version $Id$
- */
-public class UniqueArtifactIdConstraint
- extends AbstractSimpleConstraint
- implements Constraint
-{
- private StringBuffer sql = new StringBuffer();
-
- private Class<?> resultClass;
-
- /**
- * Obtain a set of unique ArtifactIds for the specified groupId.
- *
- * @param groupId the groupId to search for artifactIds within.
- */
- public UniqueArtifactIdConstraint( List<String> selectedRepositoryIds, String groupId )
- {
- appendSelect( sql, false );
- sql.append( " WHERE " );
- SqlBuilder.appendWhereSelectedRepositories( sql, "repositoryId", selectedRepositoryIds );
- sql.append( " && " );
- appendWhereSelectedGroupId( sql );
- appendGroupBy( sql );
-
- super.params = new Object[] { groupId };
- }
-
- /**
- * Obtain a set of unique ArtifactIds for the specified groupId.
- *
- * @param groupId the groupId to search for artifactIds within.
- */
- public UniqueArtifactIdConstraint( String groupId )
- {
- appendSelect( sql, false );
- sql.append( " WHERE " );
- appendWhereSelectedGroupId( sql );
- appendGroupBy( sql );
-
- super.params = new Object[] { groupId };
- }
-
- /**
- * Obtain a set of unique artifactIds with respect to their groups from the specified repository.
- *
- * @param repoId
- * @param isUnique
- */
- public UniqueArtifactIdConstraint( String repoId, boolean isUnique )
- {
- appendSelect( sql, isUnique );
- sql.append( " WHERE repositoryId == \"" + repoId + "\"" );
-
- resultClass = Object[].class;
- }
-
- @SuppressWarnings("unchecked")
- public Class getResultClass()
- {
- if( resultClass != null )
- {
- return resultClass;
- }
-
- return String.class;
- }
-
- public String getSelectSql()
- {
- return sql.toString();
- }
-
- private void appendGroupBy( StringBuffer buf )
- {
- buf.append( " GROUP BY artifactId ORDER BY artifactId ASCENDING" );
- }
-
- private void appendSelect( StringBuffer buf, boolean isUnique )
- {
- if( isUnique )
- {
- buf.append( "SELECT DISTINCT groupId, artifactId FROM " ).append( ArchivaArtifactModel.class.getName() );
- }
- else
- {
- buf.append( "SELECT artifactId FROM " ).append( ArchivaArtifactModel.class.getName() );
- }
- }
-
- private void appendWhereSelectedGroupId( StringBuffer buf )
- {
- buf.append( " groupId == selectedGroupId PARAMETERS String selectedGroupId" );
- }
-
-}
diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueGroupIdConstraint.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueGroupIdConstraint.java
deleted file mode 100644
index 459cb1bcc..000000000
--- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueGroupIdConstraint.java
+++ /dev/null
@@ -1,100 +0,0 @@
-package org.apache.maven.archiva.database.constraints;
-
-/*
- * 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.Constraint;
-import org.apache.maven.archiva.model.ArchivaArtifactModel;
-
-import java.util.List;
-
-/**
- * UniqueGroupIdConstraint
- *
- * @version $Id$
- */
-public class UniqueGroupIdConstraint
- extends AbstractSimpleConstraint
- implements Constraint
-{
- private StringBuffer sql = new StringBuffer();
-
- public UniqueGroupIdConstraint()
- {
- /* this assumes search for no groupId prefix */
- appendSelect( sql );
- appendGroupBy( sql );
- }
-
- public UniqueGroupIdConstraint( List<String> selectedRepositories )
- {
- appendSelect( sql );
- sql.append( " WHERE " );
- SqlBuilder.appendWhereSelectedRepositories( sql, "repositoryId", selectedRepositories );
- appendGroupBy( sql );
- }
-
- public UniqueGroupIdConstraint( List<String> selectedRepositories, String groupIdPrefix )
- {
- appendSelect( sql );
- sql.append( " WHERE " );
- SqlBuilder.appendWhereSelectedRepositories( sql, "repositoryId", selectedRepositories );
- sql.append( " && " );
- appendWhereGroupIdStartsWith( sql );
- appendGroupBy( sql );
-
- super.params = new Object[] { groupIdPrefix };
- }
-
- public UniqueGroupIdConstraint( String groupIdPrefix )
- {
- appendSelect( sql );
- sql.append( " WHERE " );
- appendWhereGroupIdStartsWith( sql );
- appendGroupBy( sql );
-
- super.params = new Object[] { groupIdPrefix };
- }
-
- @SuppressWarnings("unchecked")
- public Class getResultClass()
- {
- return String.class;
- }
-
- public String getSelectSql()
- {
- return sql.toString();
- }
-
- private void appendGroupBy( StringBuffer buf )
- {
- buf.append( " GROUP BY groupId ORDER BY groupId ASCENDING" );
- }
-
- private void appendSelect( StringBuffer buf )
- {
- buf.append( "SELECT groupId FROM " ).append( ArchivaArtifactModel.class.getName() );
- }
-
- private void appendWhereGroupIdStartsWith( StringBuffer buf )
- {
- buf.append( " groupId.startsWith(groupIdPrefix) PARAMETERS String groupIdPrefix" );
- }
-}
diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java
index ee78e7163..bf7e5c8cd 100644
--- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java
+++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java
@@ -19,7 +19,6 @@ package org.apache.maven.archiva.database.jdo;
* under the License.
*/
-import java.io.Serializable;
import java.util.List;
import org.apache.maven.archiva.database.ArchivaDAO;
@@ -62,11 +61,6 @@ public class JdoArchivaDAO
return jdo.queryObjects( constraint );
}
- public Object save( Serializable obj )
- {
- return jdo.saveObject( obj );
- }
-
public ArtifactDAO getArtifactDAO()
{
return artifactDAO;
diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/AllTests.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/AllTests.java
index a9b926e37..e32e01881 100644
--- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/AllTests.java
+++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/AllTests.java
@@ -36,9 +36,7 @@ public class AllTests
//$JUnit-BEGIN$
suite.addTestSuite( ArtifactsByChecksumConstraintTest.class );
suite.addTestSuite( OlderArtifactsByAgeConstraintTest.class );
- suite.addTestSuite( UniqueGroupIdConstraintTest.class );
suite.addTestSuite( OlderSnapshotArtifactsByAgeConstraintTest.class );
- suite.addTestSuite( RecentArtifactsByAgeConstraintTest.class );
//$JUnit-END$
return suite;
}
diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RecentArtifactsByAgeConstraintTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RecentArtifactsByAgeConstraintTest.java
deleted file mode 100644
index da59b761b..000000000
--- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RecentArtifactsByAgeConstraintTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package org.apache.maven.archiva.database.constraints;
-
-/*
- * 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.ArchivaDAO;
-import org.apache.maven.archiva.database.ArtifactDAO;
-import org.apache.maven.archiva.database.Constraint;
-import org.apache.maven.archiva.model.ArchivaArtifact;
-
-import java.util.Calendar;
-import java.util.List;
-
-/**
- * RecentArtifactsByAgeConstraintTest
- *
- * @version $Id$
- */
-public class RecentArtifactsByAgeConstraintTest
- extends AbstractArchivaDatabaseTestCase
-{
- private ArtifactDAO artifactDao;
-
- @Override
- protected void setUp()
- throws Exception
- {
- super.setUp();
-
- ArchivaDAO dao = (ArchivaDAO) lookup( ArchivaDAO.ROLE, "jdo" );
- artifactDao = dao.getArtifactDAO();
- }
-
- public ArchivaArtifact createArtifact( String artifactId, String version, int daysOld )
- {
- ArchivaArtifact artifact = artifactDao.createArtifact( "org.apache.maven.archiva.test", artifactId, version,
- "", "jar", "testable_repo" );
- Calendar cal = Calendar.getInstance();
- cal.add( Calendar.DAY_OF_MONTH, ( -1 ) * daysOld );
- artifact.getModel().setLastModified( cal.getTime() );
- artifact.getModel().setRepositoryId( "testable_repo" );
- return artifact;
- }
-
- public void testConstraint()
- throws Exception
- {
- ArchivaArtifact artifact;
-
- // Setup artifacts in fresh DB.
- artifact = createArtifact( "test-one", "1.0", 200 );
- artifactDao.saveArtifact( artifact );
-
- artifact = createArtifact( "test-one", "1.1", 100 );
- artifactDao.saveArtifact( artifact );
-
- artifact = createArtifact( "test-one", "1.2", 50 );
- artifactDao.saveArtifact( artifact );
-
- artifact = createArtifact( "test-two", "1.0", 200 );
- artifactDao.saveArtifact( artifact );
-
- artifact = createArtifact( "test-two", "2.0", 150 );
- artifactDao.saveArtifact( artifact );
-
- artifact = createArtifact( "test-two", "2.1", 100 );
- artifactDao.saveArtifact( artifact );
-
- artifact = createArtifact( "test-two", "3.0", 5 );
- artifactDao.saveArtifact( artifact );
-
- assertConstraint( 0, new RecentArtifactsByAgeConstraint( 2 ) );
- assertConstraint( 1, new RecentArtifactsByAgeConstraint( 7 ) );
- assertConstraint( 2, new RecentArtifactsByAgeConstraint( 90 ) );
- assertConstraint( 4, new RecentArtifactsByAgeConstraint( 100 ) );
- assertConstraint( 5, new RecentArtifactsByAgeConstraint( 150 ) );
- assertConstraint( 7, new RecentArtifactsByAgeConstraint( 9000 ) );
- }
-
- private void assertConstraint( int expectedHits, Constraint constraint )
- throws Exception
- {
- List<ArchivaArtifact> results = artifactDao.queryArtifacts( constraint );
- assertNotNull( "Recent Artifacts By Age: Not Null", results );
- assertEquals( "Recent Artifacts By Age: Results.size", expectedHits, results.size() );
- }
-}
diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraintTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraintTest.java
deleted file mode 100644
index 45a0316b4..000000000
--- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraintTest.java
+++ /dev/null
@@ -1,158 +0,0 @@
-package org.apache.maven.archiva.database.constraints;
-
-/*
- * 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.commons.lang.StringUtils;
-import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase;
-import org.apache.maven.archiva.database.ArchivaDAO;
-import org.apache.maven.archiva.database.ArchivaDatabaseException;
-import org.apache.maven.archiva.database.ArtifactDAO;
-import org.apache.maven.archiva.database.SimpleConstraint;
-import org.apache.maven.archiva.model.ArchivaArtifact;
-
-import java.util.Arrays;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * UniqueArtifactIdConstraintTest
- *
- * @version $Id$
- */
-public class UniqueArtifactIdConstraintTest
- extends AbstractArchivaDatabaseTestCase
-{
- private ArtifactDAO artifactDao;
-
- protected void setUp()
- throws Exception
- {
- super.setUp();
-
- ArchivaDAO dao = (ArchivaDAO) lookup( ArchivaDAO.ROLE, "jdo" );
- artifactDao = dao.getArtifactDAO();
- }
-
- public ArchivaArtifact createArtifact( String groupId, String artifactId, String version )
- {
- ArchivaArtifact artifact = artifactDao.createArtifact( groupId, artifactId, version, "", "jar", "testable_repo" );
- artifact.getModel().setLastModified( new Date() ); // mandatory field.
- artifact.getModel().setRepositoryId( "testable_repo" );
- return artifact;
- }
-
- public void testConstraint()
- throws Exception
- {
- setUpArtifacts();
-
- assertConstraint( new String[] {}, new UniqueArtifactIdConstraint( "org.apache" ) );
- assertConstraint( new String[] { "commons-lang" }, new UniqueArtifactIdConstraint( "commons-lang" ) );
- assertConstraint( new String[] { "test-one" }, new UniqueArtifactIdConstraint( "org.apache.maven.test" ) );
- assertConstraint( new String[] { "test-two", "test-bar" },
- new UniqueArtifactIdConstraint( "org.apache.maven.shared" ) );
- assertConstraint( new String[] { "modellong" }, new UniqueArtifactIdConstraint( "org.codehaus.modello" ) );
- }
-
- public void testConstraintDisregardGroupId()
- throws Exception
- {
- setUpArtifacts();
-
- assertConstraintWithMultipleResultTypes( new String[] { "commons-lang", "test-one", "test-two", "test-two", "test-bar", "modellong" },
- new UniqueArtifactIdConstraint( "testable_repo", true ) );
- }
-
- private void setUpArtifacts()
- throws ArchivaDatabaseException
- {
- ArchivaArtifact artifact;
-
- // Setup artifacts in fresh DB.
- artifact = createArtifact( "commons-lang", "commons-lang", "2.0" );
- artifactDao.saveArtifact( artifact );
-
- artifact = createArtifact( "commons-lang", "commons-lang", "2.1" );
- artifactDao.saveArtifact( artifact );
-
- artifact = createArtifact( "org.apache.maven.test", "test-one", "1.2" );
- artifactDao.saveArtifact( artifact );
-
- artifact = createArtifact( "org.apache.maven.test.foo", "test-two", "1.0" );
- artifactDao.saveArtifact( artifact );
-
- artifact = createArtifact( "org.apache.maven.shared", "test-two", "2.0" );
- artifactDao.saveArtifact( artifact );
-
- artifact = createArtifact( "org.apache.maven.shared", "test-two", "2.1" );
- artifactDao.saveArtifact( artifact );
-
- artifact = createArtifact( "org.apache.maven.shared", "test-bar", "2.1" );
- artifactDao.saveArtifact( artifact );
-
- artifact = createArtifact( "org.codehaus.modello", "modellong", "3.0" );
- artifactDao.saveArtifact( artifact );
- }
-
- @SuppressWarnings("unchecked")
- private void assertConstraintWithMultipleResultTypes( String[] artifactIds, SimpleConstraint constraint )
- throws Exception
- {
- String prefix = "Unique Artifact IDs: ";
-
- List<Object[]> results = (List<Object[]>) dao.query( constraint );
- assertNotNull( prefix + "Not Null", results );
- assertEquals( prefix + "Results.size", artifactIds.length, results.size() );
-
- List<String> expectedArtifactIds = Arrays.asList( artifactIds );
-
- Iterator<Object[]> it = results.iterator();
- while ( it.hasNext() )
- {
- Object[] actualArtifactIds = (Object[]) it.next();
- String actualArtifactId = ( String ) actualArtifactIds[1];
- assertTrue( prefix + "artifactId result should not be blank.", StringUtils.isNotBlank( actualArtifactId ) );
- assertTrue( prefix + " artifactId result <" + actualArtifactId + "> exists in expected artifactIds.",
- expectedArtifactIds.contains( actualArtifactId ) );
- }
- }
-
- @SuppressWarnings("unchecked")
- private void assertConstraint( String[] artifactIds, SimpleConstraint constraint )
- {
- String prefix = "Unique Artifact IDs: ";
-
- List<String> results = (List<String>) dao.query( constraint );
- assertNotNull( prefix + "Not Null", results );
- assertEquals( prefix + "Results.size", artifactIds.length, results.size() );
-
- List<String> expectedArtifactIds = Arrays.asList( artifactIds );
-
- Iterator<String> it = results.iterator();
- while ( it.hasNext() )
- {
- String actualArtifactId = (String) it.next();
- assertTrue( prefix + "artifactId result should not be blank.", StringUtils.isNotBlank( actualArtifactId ) );
- assertTrue( prefix + " artifactId result <" + actualArtifactId + "> exists in expected artifactIds.",
- expectedArtifactIds.contains( actualArtifactId ) );
- }
- }
-}
diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueGroupIdConstraintTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueGroupIdConstraintTest.java
deleted file mode 100644
index 9eaf7a4bc..000000000
--- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueGroupIdConstraintTest.java
+++ /dev/null
@@ -1,310 +0,0 @@
-package org.apache.maven.archiva.database.constraints;
-
-/*
- * 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.commons.lang.StringUtils;
-import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase;
-import org.apache.maven.archiva.database.ArchivaDAO;
-import org.apache.maven.archiva.database.ArtifactDAO;
-import org.apache.maven.archiva.database.SimpleConstraint;
-import org.apache.maven.archiva.model.ArchivaArtifact;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * UniqueGroupIdConstraintTest
- *
- * @version $Id$
- */
-public class UniqueGroupIdConstraintTest
- extends AbstractArchivaDatabaseTestCase
-{
- private ArtifactDAO artifactDao;
-
- public void testConstraintGroupIdParamCommonsLang()
- throws Exception
- {
- setupArtifacts();
-
- assertConstraint( new String[] { "commons-lang" }, new UniqueGroupIdConstraint( "commons-lang" ) );
- }
-
- public void testConstraintGroupIdParamNoRepos()
- throws Exception
- {
- try
- {
- List<String> selectedRepos = new ArrayList<String>();
- new UniqueGroupIdConstraint( selectedRepos, "org" );
- fail( "Should have thrown an IllegalArgumentException due to lack of specified repos." );
- }
- catch ( IllegalArgumentException e )
- {
- // expected path.
- }
- }
-
- public void testConstraintGroupIdParamNullRepos()
- throws Exception
- {
- try
- {
- new UniqueGroupIdConstraint( (List<String>) null, "org" );
- fail( "Should have thrown an NullPointerException due to lack of specified repos." );
- }
- catch ( NullPointerException e )
- {
- // expected path.
- }
- }
-
- public void testConstraintGroupIdParamOrg()
- throws Exception
- {
- setupArtifacts();
-
- assertConstraint( new String[] {
- "org.apache.maven.test",
- "org.apache.maven.test.foo",
- "org.apache.maven.shared",
- "org.apache.archiva",
- "org.codehaus.modello",
- "org.codehaus.mojo" }, new UniqueGroupIdConstraint( "org" ) );
- }
-
- public void testConstraintGroupIdParamOrgApache()
- throws Exception
- {
- setupArtifacts();
-
- assertConstraint( new String[] {
- "org.apache.maven.test",
- "org.apache.maven.test.foo",
- "org.apache.maven.shared",
- "org.apache.archiva" }, new UniqueGroupIdConstraint( "org.apache" ) );
- }
-
- public void testConstraintGroupIdParamOrgApacheMaven()
- throws Exception
- {
- setupArtifacts();
-
- assertConstraint( new String[] {
- "org.apache.maven.test",
- "org.apache.maven.test.foo",
- "org.apache.maven.shared" }, new UniqueGroupIdConstraint( "org.apache.maven" ) );
- }
-
- public void testConstraintGroupIdParamOrgApacheSnapshotsOnly()
- throws Exception
- {
- setupArtifacts();
-
- List<String> observableRepositories = new ArrayList<String>();
- observableRepositories.add( "snapshots" );
-
- assertConstraint( new String[] { "org.apache.archiva" }, new UniqueGroupIdConstraint( observableRepositories,
- "org.apache" ) );
- }
-
- public void testConstraintGroupIdParamOrgSnapshotsOnly()
- throws Exception
- {
- setupArtifacts();
-
- List<String> observableRepositories = new ArrayList<String>();
- observableRepositories.add( "snapshots" );
-
- assertConstraint( new String[] { "org.apache.archiva", "org.codehaus.modello", "org.codehaus.mojo" },
- new UniqueGroupIdConstraint( observableRepositories, "org" ) );
- }
-
- public void testConstraintNoGroupIdParam()
- throws Exception
- {
- setupArtifacts();
-
- assertConstraint( new String[] {
- "commons-lang",
- "org.apache.maven.test",
- "org.apache.maven.test.foo",
- "org.apache.maven.shared",
- "org.codehaus.modello",
- "org.codehaus.mojo",
- "org.apache.archiva" }, new UniqueGroupIdConstraint() );
- }
-
- public void testConstraintNoGroupIdParamCentralAndSnapshots()
- throws Exception
- {
- setupArtifacts();
-
- List<String> observableRepositories = new ArrayList<String>();
- observableRepositories.add( "central" );
- observableRepositories.add( "snapshots" );
-
- assertConstraint( new String[] {
- "commons-lang",
- "org.apache.maven.test",
- "org.apache.maven.test.foo",
- "org.apache.maven.shared",
- "org.codehaus.modello",
- "org.codehaus.mojo",
- "org.apache.archiva" }, new UniqueGroupIdConstraint( observableRepositories ) );
- }
-
- public void testConstraintNoGroupIdParamCentralOnly()
- throws Exception
- {
- setupArtifacts();
-
- List<String> observableRepositories = new ArrayList<String>();
- observableRepositories.add( "central" );
-
- assertConstraint( new String[] {
- "commons-lang",
- "org.apache.maven.test",
- "org.apache.maven.test.foo",
- "org.apache.maven.shared",
- "org.codehaus.modello" }, new UniqueGroupIdConstraint( observableRepositories ) );
- }
-
- public void testConstraintNoGroupIdParamNoRepos()
- throws Exception
- {
- try
- {
- List<String> selectedRepos = new ArrayList<String>();
- new UniqueGroupIdConstraint( selectedRepos );
- fail( "Should have thrown an IllegalArgumentException due to lack of specified repos." );
- }
- catch ( IllegalArgumentException e )
- {
- // expected path.
- }
- }
-
- public void testConstraintNoGroupIdParamNullRepos()
- throws Exception
- {
- try
- {
- new UniqueGroupIdConstraint( (List<String>) null );
- fail( "Should have thrown an NullPointerException due to lack of specified repos." );
- }
- catch ( NullPointerException e )
- {
- // expected path.
- }
- }
-
- public void testConstraintNoGroupIdParamSnapshotsOnly()
- throws Exception
- {
- setupArtifacts();
-
- List<String> observableRepositories = new ArrayList<String>();
- observableRepositories.add( "snapshots" );
-
- assertConstraint( new String[] { "org.codehaus.modello", "org.codehaus.mojo", "org.apache.archiva" },
- new UniqueGroupIdConstraint( observableRepositories ) );
- }
-
- @SuppressWarnings("unchecked")
- private void assertConstraint( String[] expectedGroupIds, SimpleConstraint constraint )
- throws Exception
- {
- String prefix = "Unique Group IDs: ";
-
- List<String> results = (List<String>) dao.query( constraint );
- assertNotNull( prefix + "Not Null", results );
- assertEquals( prefix + "Results.size", expectedGroupIds.length, results.size() );
-
- List<String> groupIdList = Arrays.asList( expectedGroupIds );
-
- Iterator<String> it = results.iterator();
- while ( it.hasNext() )
- {
- String actualGroupId = (String) it.next();
- assertTrue( prefix + "groupId result should not be blank.", StringUtils.isNotBlank( actualGroupId ) );
- assertTrue( prefix + " groupId result <" + actualGroupId + "> exists in expected GroupIds.", groupIdList
- .contains( actualGroupId ) );
- }
- }
-
- private ArchivaArtifact createArtifact( String repoId, String groupId, String artifactId, String version )
- {
- ArchivaArtifact artifact = artifactDao.createArtifact( groupId, artifactId, version, "", "jar", "testrepo" );
- artifact.getModel().setLastModified( new Date() ); // mandatory field.
- artifact.getModel().setRepositoryId( repoId );
- return artifact;
- }
-
- private void setupArtifacts()
- throws Exception
- {
- ArchivaArtifact artifact;
-
- // Setup artifacts in fresh DB.
- artifact = createArtifact( "central", "commons-lang", "commons-lang", "2.0" );
- artifactDao.saveArtifact( artifact );
-
- artifact = createArtifact( "central", "commons-lang", "commons-lang", "2.1" );
- artifactDao.saveArtifact( artifact );
-
- artifact = createArtifact( "central", "org.apache.maven.test", "test-one", "1.2" );
- artifactDao.saveArtifact( artifact );
-
- artifact = createArtifact( "central", "org.apache.maven.test.foo", "test-two", "1.0" );
- artifactDao.saveArtifact( artifact );
-
- artifact = createArtifact( "central", "org.apache.maven.shared", "test-two", "2.0" );
- artifactDao.saveArtifact( artifact );
-
- artifact = createArtifact( "central", "org.apache.maven.shared", "test-two", "2.1" );
- artifactDao.saveArtifact( artifact );
-
- artifact = createArtifact( "central", "org.codehaus.modello", "test-two", "3.0" );
- artifactDao.saveArtifact( artifact );
-
- // Snapshots repository artifacts
- artifact = createArtifact( "snapshots", "org.codehaus.modello", "test-three", "1.0-SNAPSHOT" );
- artifactDao.saveArtifact( artifact );
-
- artifact = createArtifact( "snapshots", "org.codehaus.mojo", "testable-maven-plugin", "2.1-SNAPSHOT" );
- artifactDao.saveArtifact( artifact );
-
- artifact = createArtifact( "snapshots", "org.apache.archiva", "testable", "1.1-alpha-1-20070822.033400-43" );
- artifactDao.saveArtifact( artifact );
- }
-
- protected void setUp()
- throws Exception
- {
- super.setUp();
-
- ArchivaDAO dao = (ArchivaDAO) lookup( ArchivaDAO.ROLE, "jdo" );
- artifactDao = dao.getArtifactDAO();
- }
-}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/ArchivaDAOStub.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/ArchivaDAOStub.java
index 973da10bb..3553dcd8c 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/ArchivaDAOStub.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/ArchivaDAOStub.java
@@ -19,7 +19,6 @@ package org.apache.maven.archiva.web.action.admin.repositories;
* under the License.
*/
-import java.io.Serializable;
import java.util.List;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
@@ -27,9 +26,7 @@ import org.apache.maven.archiva.database.ArchivaDAO;
import org.apache.maven.archiva.database.ArtifactDAO;
import org.apache.maven.archiva.database.RepositoryProblemDAO;
import org.apache.maven.archiva.database.SimpleConstraint;
-import org.apache.maven.archiva.database.constraints.UniqueArtifactIdConstraint;
import org.apache.maven.archiva.database.constraints.UniqueFieldConstraint;
-import org.apache.maven.archiva.database.constraints.UniqueGroupIdConstraint;
import org.apache.maven.archiva.database.constraints.UniqueVersionConstraint;
/**
@@ -46,10 +43,6 @@ public class ArchivaDAOStub
private List<String> versions;
- private List<String> groups;
-
- private List<String> artifacts;
-
private List<String> repositoryIds;
private RepositoryProblemDAO repositoryProblemDAO;
@@ -60,14 +53,6 @@ public class ArchivaDAOStub
{
return versions;
}
- else if ( constraint instanceof UniqueGroupIdConstraint )
- {
- return groups;
- }
- else if ( constraint instanceof UniqueArtifactIdConstraint )
- {
- return artifacts;
- }
else if ( constraint instanceof UniqueFieldConstraint )
{
return repositoryIds;
@@ -75,11 +60,6 @@ public class ArchivaDAOStub
throw new UnsupportedOperationException();
}
- public Object save( Serializable obj )
- {
- throw new UnsupportedOperationException( "query not implemented for stub" );
- }
-
public ArtifactDAO getArtifactDAO()
{
return artifactDao;
@@ -100,16 +80,6 @@ public class ArchivaDAOStub
this.versions = versions;
}
- public void setGroups( List<String> groups )
- {
- this.groups = groups;
- }
-
- public void setArtifacts( List<String> artifacts )
- {
- this.artifacts = artifacts;
- }
-
public void setRepositoryIds( List<String> repositoryIds )
{
this.repositoryIds = repositoryIds;