From 7b52510e87eeda654f6696131c419fb9a0286fb7 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Mon, 26 Feb 2007 19:20:59 +0000 Subject: [PATCH] Correcting unit test failures. git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@511956 13f79535-47bb-0310-9956-ffa450edef68 --- archiva-repository-layer/pom.xml | 29 +++++++++++ .../layer/CachedRepositoryQueryLayer.java | 14 ++--- .../resources/META-INF/plexus/components.xml | 43 +++++++++++++++ .../org/apache/maven/archiva/AllTests.java | 44 ++++++++++++++++ .../apache/maven/archiva/layer/AllTests.java | 44 ++++++++++++++++ .../layer/CachedRepositoryQueryLayerTest.java | 12 ++--- .../maven/archiva/repository/AllTests.java | 43 +++++++++++++++ .../layer/CachedRepositoryQueryLayerTest.xml | 52 +++++++++++++++++++ 8 files changed, 264 insertions(+), 17 deletions(-) create mode 100644 archiva-repository-layer/src/main/resources/META-INF/plexus/components.xml create mode 100644 archiva-repository-layer/src/test/java/org/apache/maven/archiva/AllTests.java create mode 100644 archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/AllTests.java create mode 100644 archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/AllTests.java create mode 100644 archiva-repository-layer/src/test/resources/org/apache/maven/archiva/layer/CachedRepositoryQueryLayerTest.xml diff --git a/archiva-repository-layer/pom.xml b/archiva-repository-layer/pom.xml index a0135a5c6..fa9a51ab8 100644 --- a/archiva-repository-layer/pom.xml +++ b/archiva-repository-layer/pom.xml @@ -51,5 +51,34 @@ org.apache.maven maven-repository-metadata + + + org.codehaus.plexus.cache + plexus-cache-hashmap + 1.0-alpha-1 + test + + + + + org.codehaus.plexus + plexus-maven-plugin + + + merge + + merge-descriptors + + + + ${basedir}/src/main/resources/META-INF/plexus/components.xml + ${project.build.directory}/generated-resources/plexus/META-INF/plexus/components.xml + + + + + + + diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/CachedRepositoryQueryLayer.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/CachedRepositoryQueryLayer.java index 953827b18..65f03c6a6 100644 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/CachedRepositoryQueryLayer.java +++ b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/CachedRepositoryQueryLayer.java @@ -35,7 +35,7 @@ public class CachedRepositoryQueryLayer implements RepositoryQueryLayer { /** - * @plexus.requirement + * @plexus.requirement role-hint="repository-query" */ private Cache cache; @@ -43,16 +43,10 @@ public class CachedRepositoryQueryLayer * @plexus.requirement */ private RepositoryQueryLayer layer; - - public CachedRepositoryQueryLayer( RepositoryQueryLayer layer ) - { - this.layer = layer; - } - - public CachedRepositoryQueryLayer( RepositoryQueryLayer layer, Cache cache ) + + public CachedRepositoryQueryLayer() { - this.cache = cache; - this.layer = layer; + } public boolean containsArtifact( Artifact artifact ) diff --git a/archiva-repository-layer/src/main/resources/META-INF/plexus/components.xml b/archiva-repository-layer/src/main/resources/META-INF/plexus/components.xml new file mode 100644 index 000000000..c2ee003f5 --- /dev/null +++ b/archiva-repository-layer/src/main/resources/META-INF/plexus/components.xml @@ -0,0 +1,43 @@ + + + + + + + + org.codehaus.plexus.cache.Cache + repository-query + org.codehaus.plexus.cache.ehcache.EhcacheCache + EhcacheCache + + 600 + true + ${java.io.tmpdir}/ehcache/repo-query + false + 1000 + LRU + repository-query + false + 600 + 300 + + + + diff --git a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/AllTests.java b/archiva-repository-layer/src/test/java/org/apache/maven/archiva/AllTests.java new file mode 100644 index 000000000..e23eb09f7 --- /dev/null +++ b/archiva-repository-layer/src/test/java/org/apache/maven/archiva/AllTests.java @@ -0,0 +1,44 @@ +package org.apache.maven.archiva; + +/* + * 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 junit.framework.Test; +import junit.framework.TestSuite; + +/** + * AllTests - conveinence test suite for IDE users. + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class AllTests +{ + + public static Test suite() + { + TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva" ); + //$JUnit-BEGIN$ + suite.addTest( org.apache.maven.archiva.repository.AllTests.suite() ); + suite.addTest( org.apache.maven.archiva.layer.AllTests.suite() ); + //$JUnit-END$ + return suite; + } + +} diff --git a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/AllTests.java b/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/AllTests.java new file mode 100644 index 000000000..c87f2710e --- /dev/null +++ b/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/AllTests.java @@ -0,0 +1,44 @@ +package org.apache.maven.archiva.layer; + +/* + * 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 junit.framework.Test; +import junit.framework.TestSuite; + +/** + * AllTests + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class AllTests +{ + + public static Test suite() + { + TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.layer" ); + //$JUnit-BEGIN$ + suite.addTestSuite( CachedRepositoryQueryLayerTest.class ); + suite.addTestSuite( DefaultRepositoryQueryLayerTest.class ); + //$JUnit-END$ + return suite; + } + +} diff --git a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/CachedRepositoryQueryLayerTest.java b/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/CachedRepositoryQueryLayerTest.java index b5435fc62..f7da091cc 100644 --- a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/CachedRepositoryQueryLayerTest.java +++ b/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/CachedRepositoryQueryLayerTest.java @@ -1,7 +1,5 @@ package org.apache.maven.archiva.layer; -import org.codehaus.plexus.cache.Cache; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -21,22 +19,22 @@ import org.codehaus.plexus.cache.Cache; * under the License. */ + /** + * CachedRepositoryQueryLayerTest * + * @author Joakim Erdfelt + * @version $Id$ */ public class CachedRepositoryQueryLayerTest extends AbstractRepositoryQueryLayerTestCase { - private Cache cache; - protected void setUp() throws Exception { super.setUp(); - cache = (Cache) lookup( Cache.ROLE, "test" ); - - queryLayer = new CachedRepositoryQueryLayer( new DefaultRepositoryQueryLayer( repository ), cache ); + queryLayer = (RepositoryQueryLayer) lookup( RepositoryQueryLayer.ROLE, "test-cached" ); } public void testUseFileCache() diff --git a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/AllTests.java b/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/AllTests.java new file mode 100644 index 000000000..e25a55e80 --- /dev/null +++ b/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/AllTests.java @@ -0,0 +1,43 @@ +package org.apache.maven.archiva.repository; + +/* + * 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 junit.framework.Test; +import junit.framework.TestSuite; + +/** + * AllTests + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class AllTests +{ + + public static Test suite() + { + TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.repository" ); + //$JUnit-BEGIN$ + suite.addTestSuite( RepositoryURLTest.class ); + //$JUnit-END$ + return suite; + } + +} diff --git a/archiva-repository-layer/src/test/resources/org/apache/maven/archiva/layer/CachedRepositoryQueryLayerTest.xml b/archiva-repository-layer/src/test/resources/org/apache/maven/archiva/layer/CachedRepositoryQueryLayerTest.xml new file mode 100644 index 000000000..8ff658ab7 --- /dev/null +++ b/archiva-repository-layer/src/test/resources/org/apache/maven/archiva/layer/CachedRepositoryQueryLayerTest.xml @@ -0,0 +1,52 @@ + + + + + + + + org.apache.maven.archiva.layer.RepositoryQueryLayer + test-cached + org.apache.maven.archiva.layer.CachedRepositoryQueryLayer + CachedRepositoryQueryLayer - simple wrapper around another non-cached Repository Query Layer. + + + org.codehaus.plexus.cache.Cache + test-repository-query + cache + + + org.apache.maven.archiva.layer.RepositoryQueryLayer + layer + + + + + + org.codehaus.plexus.cache.Cache + test-repository-query + org.codehaus.plexus.cache.hashmap.HashMapCache + + 1.0 + 0 + + + + \ No newline at end of file -- 2.39.5