You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by jd...@apache.org on 2009/02/18 01:55:31 UTC
svn commit: r745335 - in /archiva/branches/archiva-with-new-repoapi: ./
archiva-modules/archiva-base/ archiva-modules/archiva-base/archiva-event/
archiva-modules/archiva-base/archiva-event/src/
archiva-modules/archiva-base/archiva-event/src/main/ archi...
Author: jdumay
Date: Wed Feb 18 00:55:30 2009
New Revision: 745335
URL: http://svn.apache.org/viewvc?rev=745335&view=rev
Log:
Adding Archiva event, tests for the repository factory and fixing test failures
Added:
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/pom.xml
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/AsynchronousEventBus.java
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/Event.java
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/EventBus.java
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/EventEmitter.java
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/EventMessage.java
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/EventObserver.java
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/resources/
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/test/
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/test/java/
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/test/java/org/
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/test/java/org/apache/
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/test/java/org/apache/archiva/
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/test/java/org/apache/archiva/event/
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/test/java/org/apache/archiva/event/AsynchronousEventBusTest.java
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/test/java/org/apache/archiva/event/EventTest.java
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/test/java/org/apache/archiva/repository/DefaultRepositoryFactoryTest.java
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/test/resources/
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/test/resources/org/
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/test/resources/org/apache/
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/test/resources/org/apache/archiva/
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/test/resources/org/apache/archiva/repository/
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/test/resources/org/apache/archiva/repository/DefaultRepositoryFactoryTest.xml
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/test/resources/repository-archiva.xml
Modified:
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/RepositoryContentFactory.java
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/pom.xml
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/main/java/org/apache/archiva/repository/DefaultRepositoryFactory.java
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/main/java/org/apache/archiva/repository/LegacyRepositoryManager.java
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/pom.xml
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-web/archiva-repository-servlet/src/test/java/org/apache/archiva/web/servlet/AbstractRepositoryServletTestCase.java
archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-web/archiva-repository-servlet/src/test/java/org/apache/archiva/web/servlet/RepositoryServletTest.java
archiva/branches/archiva-with-new-repoapi/pom.xml
Added: archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/pom.xml
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/pom.xml?rev=745335&view=auto
==============================================================================
--- archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/pom.xml (added)
+++ archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/pom.xml Wed Feb 18 00:55:30 2009
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-event</artifactId>
+ <packaging>jar</packaging>
+ <version>1.2-SNAPSHOT</version>
+ <name>Archiva Base :: Event</name>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Added: archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/AsynchronousEventBus.java
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/AsynchronousEventBus.java?rev=745335&view=auto
==============================================================================
--- archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/AsynchronousEventBus.java (added)
+++ archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/AsynchronousEventBus.java Wed Feb 18 00:55:30 2009
@@ -0,0 +1,117 @@
+package org.apache.archiva.event;
+
+/*
+ * 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.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+
+/**
+ * Simple Async Event Bus implementation
+ *
+ * @author jdumay
+ */
+public class AsynchronousEventBus implements EventBus
+{
+ private final Set<EventObserver> observers = Collections.synchronizedSet(new HashSet());
+
+ private final BlockingQueue<Event> events = new LinkedBlockingQueue<Event>();
+
+ private final Thread workerThread;
+
+ private final int threads;
+
+ public AsynchronousEventBus(int threads)
+ {
+ this.threads = threads;
+ workerThread = new Thread(new WorkerRunnable());
+ workerThread.start();
+ }
+
+ public void emit(EventEmitter emitter, EventMessage message)
+ {
+ events.offer(new Event(emitter, message));
+ }
+
+ public void subscribe(EventObserver observer)
+ {
+ observers.add(observer);
+ }
+
+ public void unsubscribe(EventObserver observer)
+ {
+ observers.remove(observer);
+ }
+
+ public Set<EventObserver> getObservers() {
+ return new HashSet<EventObserver>(observers);
+ }
+
+ class WorkerRunnable implements Runnable
+ {
+ private final ExecutorService service;
+
+ public WorkerRunnable()
+ {
+ service = Executors.newFixedThreadPool(threads);
+ }
+
+ public void run()
+ {
+ while (true)
+ {
+ dequeueAndExecute();
+ }
+ }
+
+ private void dequeueAndExecute()
+ {
+ try
+ {
+ final Event event = events.take();
+ for (final EventObserver observer : observers)
+ {
+ service.execute(new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ observer.observe(event);
+ }
+ finally
+ {
+ //log me
+ }
+ }
+ });
+ }
+ }
+ catch (InterruptedException e)
+ {
+ //Do nothing
+ }
+ }
+ }
+}
Added: archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/Event.java
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/Event.java?rev=745335&view=auto
==============================================================================
--- archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/Event.java (added)
+++ archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/Event.java Wed Feb 18 00:55:30 2009
@@ -0,0 +1,55 @@
+package org.apache.archiva.event;
+
+/*
+ * 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.
+ */
+
+/**
+ * Encaptulation of both the EventEmitter and the EventMessage
+ * to represent a single event
+ */
+public final class Event
+{
+ private final EventEmitter emitter;
+
+ private final EventMessage message;
+
+ public Event(EventEmitter emitter, EventMessage message)
+ {
+ this.emitter = emitter;
+ this.message = message;
+ }
+
+ /**
+ * Get the Emitter who emitted the Event
+ * @return emitter
+ */
+ public EventEmitter getEmitter()
+ {
+ return emitter;
+ }
+
+ /**
+ * Get the EventMessage
+ * @return message
+ */
+ public EventMessage getMessage()
+ {
+ return message;
+ }
+}
Added: archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/EventBus.java
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/EventBus.java?rev=745335&view=auto
==============================================================================
--- archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/EventBus.java (added)
+++ archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/EventBus.java Wed Feb 18 00:55:30 2009
@@ -0,0 +1,53 @@
+package org.apache.archiva.event;
+
+/*
+ * 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.Set;
+
+/**
+ * Allows implementer to emit to, subscribe and unsubscribe EventObservers
+ */
+public interface EventBus
+{
+ /**
+ * Emit a event
+ * @param emitter
+ * @param message
+ */
+ void emit(EventEmitter emitter, EventMessage message);
+
+ /**
+ * Allows the subscriber to receive messages from this event bus
+ * @param observer
+ */
+ void subscribe(EventObserver observer);
+
+ /**
+ * Stops the observer from receiving any messages
+ * @param observer
+ */
+ void unsubscribe(EventObserver observer);
+
+ /**
+ * Get the set of registered EventObservers
+ * @return
+ */
+ Set<EventObserver> getObservers();
+}
Added: archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/EventEmitter.java
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/EventEmitter.java?rev=745335&view=auto
==============================================================================
--- archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/EventEmitter.java (added)
+++ archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/EventEmitter.java Wed Feb 18 00:55:30 2009
@@ -0,0 +1,24 @@
+package org.apache.archiva.event;
+
+/*
+ * 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.
+ */
+
+public interface EventEmitter
+{
+}
Added: archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/EventMessage.java
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/EventMessage.java?rev=745335&view=auto
==============================================================================
--- archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/EventMessage.java (added)
+++ archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/EventMessage.java Wed Feb 18 00:55:30 2009
@@ -0,0 +1,24 @@
+package org.apache.archiva.event;
+
+/*
+ * 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.
+ */
+
+public interface EventMessage
+{
+}
Added: archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/EventObserver.java
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/EventObserver.java?rev=745335&view=auto
==============================================================================
--- archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/EventObserver.java (added)
+++ archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/main/java/org/apache/archiva/event/EventObserver.java Wed Feb 18 00:55:30 2009
@@ -0,0 +1,25 @@
+package org.apache.archiva.event;
+
+/*
+ * 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.
+ */
+
+public interface EventObserver
+{
+ void observe(Event event);
+}
Added: archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/test/java/org/apache/archiva/event/AsynchronousEventBusTest.java
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/test/java/org/apache/archiva/event/AsynchronousEventBusTest.java?rev=745335&view=auto
==============================================================================
--- archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/test/java/org/apache/archiva/event/AsynchronousEventBusTest.java (added)
+++ archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/test/java/org/apache/archiva/event/AsynchronousEventBusTest.java Wed Feb 18 00:55:30 2009
@@ -0,0 +1,70 @@
+package org.apache.archiva.event;
+
+/*
+ * 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.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import junit.framework.TestCase;
+
+public class AsynchronousEventBusTest extends TestCase
+{
+ public void testSubscribeUnsubscribe() throws Exception
+ {
+ AsynchronousEventBus bus = new AsynchronousEventBus(1);
+ MockObserver observer = new MockObserver();
+
+ assertEquals(0, bus.getObservers().size());
+
+ bus.subscribe(observer);
+ assertTrue(bus.getObservers().contains(observer));
+
+ bus.unsubscribe(observer);
+ assertFalse(bus.getObservers().contains(bus));
+ }
+
+ public void testAllEventsAreObserved() throws Exception
+ {
+ AsynchronousEventBus bus = new AsynchronousEventBus(1);
+ MockObserver observer = new MockObserver();
+ bus.subscribe(observer);
+
+ for (int i = 0; i < 10; i++)
+ {
+ bus.emit(new EventEmitter() {}, new EventMessage() {});
+ }
+
+ while (observer.observedEvents.size() != 10)
+ {
+ }
+
+ assertEquals(10, observer.observedEvents.size());
+ }
+
+ class MockObserver implements EventObserver
+ {
+ final List<Event> observedEvents = Collections.synchronizedList(new ArrayList());
+
+ public void observe(Event event)
+ {
+ observedEvents.add(event);
+ }
+ }
+}
Added: archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/test/java/org/apache/archiva/event/EventTest.java
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/test/java/org/apache/archiva/event/EventTest.java?rev=745335&view=auto
==============================================================================
--- archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/test/java/org/apache/archiva/event/EventTest.java (added)
+++ archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-event/src/test/java/org/apache/archiva/event/EventTest.java Wed Feb 18 00:55:30 2009
@@ -0,0 +1,35 @@
+package org.apache.archiva.event;
+
+/*
+ * 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.TestCase;
+
+public class EventTest extends TestCase
+{
+ public void testEvent()
+ {
+ EventEmitter emitter = new EventEmitter() {};
+ EventMessage message = new EventMessage() {};
+ Event event = new Event(emitter, message);
+
+ assertEquals(emitter, event.getEmitter());
+ assertEquals(message, event.getMessage());
+ }
+}
Modified: archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/RepositoryContentFactory.java
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/RepositoryContentFactory.java?rev=745335&r1=745334&r2=745335&view=diff
==============================================================================
--- archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/RepositoryContentFactory.java (original)
+++ archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/RepositoryContentFactory.java Wed Feb 18 00:55:30 2009
@@ -34,8 +34,8 @@
import org.codehaus.plexus.registry.Registry;
import org.codehaus.plexus.registry.RegistryListener;
-import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.collections.map.UnmodifiableMap;
/**
@@ -62,8 +62,8 @@
public RepositoryContentFactory()
{
- managedContentMap = new HashMap<String, ManagedRepositoryContent>();
- remoteContentMap = new HashMap<String, RemoteRepositoryContent>();
+ managedContentMap = new ConcurrentHashMap<String, ManagedRepositoryContent>();
+ remoteContentMap = new ConcurrentHashMap<String, RemoteRepositoryContent>();
}
/**
@@ -72,6 +72,21 @@
*/
public Map<String, ManagedRepositoryContent> getManagedContentMap()
{
+ if (managedContentMap.isEmpty())
+ {
+ for (final ManagedRepositoryConfiguration configuration : archivaConfiguration.getConfiguration().getManagedRepositories())
+ {
+ try
+ {
+ managedContentMap.put(configuration.getId(), createManagedRepositoryContent(configuration));
+ }
+ catch (RepositoryException e)
+ {
+ //Do nothing
+ }
+ }
+ }
+
return UnmodifiableMap.decorate(managedContentMap);
}
@@ -81,6 +96,21 @@
*/
public Map<String, RemoteRepositoryContent> getRemoteContentMap()
{
+ if (remoteContentMap.isEmpty())
+ {
+ for (final RemoteRepositoryConfiguration configuration : archivaConfiguration.getConfiguration().getRemoteRepositories())
+ {
+ try
+ {
+ remoteContentMap.put(configuration.getId(), createRemoteRepositoryContent(configuration));
+ }
+ catch ( RepositoryException e )
+ {
+ // Do nothing
+ }
+ }
+ }
+
return UnmodifiableMap.decorate(remoteContentMap);
}
@@ -102,26 +132,13 @@
return repo;
}
- ManagedRepositoryConfiguration repoConfig = archivaConfiguration.getConfiguration()
- .findManagedRepositoryById( repoId );
- if ( repoConfig == null )
+ ManagedRepositoryConfiguration configuration = archivaConfiguration.getConfiguration().findManagedRepositoryById( repoId );
+ if ( configuration == null )
{
throw new RepositoryNotFoundException( "Unable to find managed repository configuration for id:" + repoId );
}
- try
- {
- repo = (ManagedRepositoryContent) container.lookup( ManagedRepositoryContent.class, repoConfig.getLayout() );
- repo.setRepository( repoConfig );
- managedContentMap.put( repoId, repo );
- }
- catch ( ComponentLookupException e )
- {
- throw new RepositoryException( "Specified layout [" + repoConfig.getLayout()
- + "] on managed repository id [" + repoId + "] is not valid.", e );
- }
-
- return repo;
+ return createManagedRepositoryContent(configuration);
}
public RemoteRepositoryContent getRemoteRepositoryContent( String repoId )
@@ -134,28 +151,50 @@
return repo;
}
- RemoteRepositoryConfiguration repoConfig = archivaConfiguration.getConfiguration()
- .findRemoteRepositoryById( repoId );
- if ( repoConfig == null )
+ RemoteRepositoryConfiguration configuration = archivaConfiguration.getConfiguration().findRemoteRepositoryById( repoId );
+ if ( configuration == null )
{
throw new RepositoryNotFoundException( "Unable to find remote repository configuration for id:" + repoId );
}
+ return createRemoteRepositoryContent(configuration);
+ }
+
+ private RemoteRepositoryContent createRemoteRepositoryContent(RemoteRepositoryConfiguration configuration)
+ throws RepositoryException
+ {
+ RemoteRepositoryContent repositoryContent = null;
try
{
- repo = (RemoteRepositoryContent) container.lookup( RemoteRepositoryContent.class, repoConfig.getLayout() );
- repo.setRepository( repoConfig );
- remoteContentMap.put( repoId, repo );
+ repositoryContent = (RemoteRepositoryContent) container.lookup( RemoteRepositoryContent.class, configuration.getLayout() );
+ repositoryContent.setRepository( configuration );
}
catch ( ComponentLookupException e )
{
- throw new RepositoryException( "Specified layout [" + repoConfig.getLayout()
- + "] on remote repository id [" + repoId + "] is not valid.", e );
+ throw new RepositoryException( "Specified layout [" + configuration.getLayout()
+ + "] on remote repository id [" + configuration.getId() + "] is not valid.", e );
}
+ return repositoryContent;
+ }
- return repo;
+ private ManagedRepositoryContent createManagedRepositoryContent(ManagedRepositoryConfiguration configuration)
+ throws RepositoryException
+ {
+ ManagedRepositoryContent repositoryContent = null;
+ try
+ {
+ repositoryContent = (ManagedRepositoryContent) container.lookup( ManagedRepositoryContent.class, configuration.getLayout() );
+ repositoryContent.setRepository( configuration );
+ }
+ catch ( ComponentLookupException e )
+ {
+ throw new RepositoryException( "Specified layout [" + configuration.getLayout()
+ + "] on managed repository id [" + configuration.getId() + "] is not valid.", e );
+ }
+ return repositoryContent;
}
+
public void contextualize( Context context )
throws ContextException
{
Modified: archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/pom.xml
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/pom.xml?rev=745335&r1=745334&r2=745335&view=diff
==============================================================================
--- archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/pom.xml (original)
+++ archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/pom.xml Wed Feb 18 00:55:30 2009
@@ -15,31 +15,40 @@
~ 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">
- <parent>
- <artifactId>archiva-base</artifactId>
+ <parent>
+ <artifactId>archiva-base</artifactId>
+ <groupId>org.apache.archiva</groupId>
+ <version>1.2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
<groupId>org.apache.archiva</groupId>
- <version>1.2-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.archiva</groupId>
- <artifactId>archiva-repository</artifactId>
- <name>Archiva Base :: Repository</name>
- <dependencies>
- <dependency>
- <groupId>org.apache.archiva</groupId>
- <artifactId>archiva-repository-layer</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.archiva</groupId>
- <artifactId>archiva-repository-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.archiva</groupId>
- <artifactId>archiva-configuration</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- </dependency>
- </dependencies>
+ <artifactId>archiva-repository</artifactId>
+ <name>Archiva Base :: Repository</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-repository-layer</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-repository-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-configuration</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-spring</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
</project>
Modified: archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/main/java/org/apache/archiva/repository/DefaultRepositoryFactory.java
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/main/java/org/apache/archiva/repository/DefaultRepositoryFactory.java?rev=745335&r1=745334&r2=745335&view=diff
==============================================================================
--- archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/main/java/org/apache/archiva/repository/DefaultRepositoryFactory.java (original)
+++ archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/main/java/org/apache/archiva/repository/DefaultRepositoryFactory.java Wed Feb 18 00:55:30 2009
@@ -23,11 +23,14 @@
import java.util.Map;
import org.apache.archiva.repository.api.Repository;
import org.apache.archiva.repository.api.RepositoryFactory;
+import org.apache.log4j.Logger;
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
import org.apache.maven.archiva.repository.RepositoryContentFactory;
public class DefaultRepositoryFactory implements RepositoryFactory
{
+ private static final Logger log = Logger.getLogger(DefaultRepositoryFactory.class);
+
private final RepositoryContentFactory repositoryContentFactory;
public DefaultRepositoryFactory(RepositoryContentFactory repositoryContentFactory)
@@ -41,7 +44,14 @@
final HashMap<String, Repository> repositories = new HashMap<String, Repository>();
for (final String repositoryId : contentMap.keySet())
{
- repositories.put(repositoryId, contentMap.get(repositoryId));
+ final ManagedRepositoryContent content = contentMap.get(repositoryId);
+
+ if (!content.getLocalPath().exists() && !content.getLocalPath().mkdirs())
+ {
+ log.error("Directory could not be created for repository <" + content.getId() + "> with missing directory");
+ }
+
+ repositories.put(repositoryId, content);
}
return repositories;
}
Modified: archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/main/java/org/apache/archiva/repository/LegacyRepositoryManager.java
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/main/java/org/apache/archiva/repository/LegacyRepositoryManager.java?rev=745335&r1=745334&r2=745335&view=diff
==============================================================================
--- archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/main/java/org/apache/archiva/repository/LegacyRepositoryManager.java (original)
+++ archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/main/java/org/apache/archiva/repository/LegacyRepositoryManager.java Wed Feb 18 00:55:30 2009
@@ -1,5 +1,24 @@
package org.apache.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 java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
Added: archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/test/java/org/apache/archiva/repository/DefaultRepositoryFactoryTest.java
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/test/java/org/apache/archiva/repository/DefaultRepositoryFactoryTest.java?rev=745335&view=auto
==============================================================================
--- archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/test/java/org/apache/archiva/repository/DefaultRepositoryFactoryTest.java (added)
+++ archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/test/java/org/apache/archiva/repository/DefaultRepositoryFactoryTest.java Wed Feb 18 00:55:30 2009
@@ -0,0 +1,135 @@
+package org.apache.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 java.io.File;
+import org.apache.archiva.repository.api.Repository;
+import org.apache.archiva.repository.api.RepositoryFactory;
+import org.apache.commons.io.FileUtils;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.Configuration;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.codehaus.plexus.spring.PlexusInSpringTestCase;
+
+public class DefaultRepositoryFactoryTest extends PlexusInSpringTestCase
+{
+ private static final String NEW_REPOSITORY_ID = "new-id";
+ private static final String NEW_REPOSITORY_NAME = "New Repository";
+ protected static final String REPOID_INTERNAL = "internal";
+
+ private ArchivaConfiguration archivaConfiguration;
+ private File repoRootInternal;
+ private RepositoryFactory repositoryFactory;
+
+ public void testGetRepository()
+ throws Exception
+ {
+ assertRepositoryValid( repositoryFactory, REPOID_INTERNAL );
+ }
+
+ public void testGetRepositoryAfterDelete()
+ throws Exception
+ {
+ assertNotNull( repositoryFactory );
+
+ Configuration c = archivaConfiguration.getConfiguration();
+ c.removeManagedRepository( c.findManagedRepositoryById( REPOID_INTERNAL ) );
+ saveConfiguration( archivaConfiguration );
+
+ Repository repository = repositoryFactory.getRepositories().get(REPOID_INTERNAL);
+ assertNull( repository );
+ }
+
+ public void testGetRepositoryAfterAdd()
+ throws Exception
+ {
+ assertNotNull( repositoryFactory );
+
+ Configuration c = archivaConfiguration.getConfiguration();
+ ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
+ repo.setId( NEW_REPOSITORY_ID );
+ repo.setName( NEW_REPOSITORY_NAME );
+ File repoRoot = new File( getBasedir(), "target/test-repository-root" );
+ if ( !repoRoot.exists() )
+ {
+ repoRoot.mkdirs();
+ }
+ repo.setLocation( repoRoot.getAbsolutePath() );
+ c.addManagedRepository( repo );
+ saveConfiguration( archivaConfiguration );
+
+ Repository repository = repositoryFactory.getRepositories().get(NEW_REPOSITORY_ID);
+ assertNotNull( repository );
+ assertEquals( NEW_REPOSITORY_NAME, repository.getName() );
+
+ // check other is still intact
+ assertRepositoryValid( repositoryFactory, REPOID_INTERNAL );
+ }
+
+ @Override
+ protected String getPlexusConfigLocation()
+ {
+ return "org/apache/archiva/repository/DefaultRepositoryFactoryTest.xml";
+ }
+
+ protected ManagedRepositoryConfiguration createManagedRepository( String id, String name, File location )
+ {
+ ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
+ repo.setId( id );
+ repo.setName( name );
+ repo.setLocation( location.getAbsolutePath() );
+ return repo;
+ }
+
+ protected void saveConfiguration( ArchivaConfiguration archivaConfiguration )
+ throws Exception
+ {
+ archivaConfiguration.save( archivaConfiguration.getConfiguration() );
+ }
+
+ protected void assertRepositoryValid( RepositoryFactory repositoryFactory, String repoId )
+ {
+ Repository repository = repositoryFactory.getRepositories().get(repoId);
+ assertNotNull( "Archiva Managed Repository id:<" + repoId + "> should exist.", repository );
+ assertTrue( "Archiva Managed Repository id:<" + repoId + "> should have a valid location on disk.", repository.getLocalPath().exists()
+ && repository.getLocalPath().isDirectory() );
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ String appserverBase = getTestFile( "target/appserver-base" ).getAbsolutePath();
+ System.setProperty( "appserver.base", appserverBase );
+
+ File testConf = getTestFile( "src/test/resources/repository-archiva.xml" );
+ File testConfDest = new File( appserverBase, "conf/archiva.xml" );
+ FileUtils.copyFile( testConf, testConfDest );
+
+ archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class );
+ repoRootInternal = new File( appserverBase, "data/repositories/internal" );
+ Configuration config = archivaConfiguration.getConfiguration();
+
+ config.addManagedRepository( createManagedRepository( REPOID_INTERNAL, "Internal Test Repo", repoRootInternal ) );
+ saveConfiguration( archivaConfiguration );
+
+ repositoryFactory = (RepositoryFactory)lookup(RepositoryFactory.class);
+ }
+}
Added: archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/test/resources/org/apache/archiva/repository/DefaultRepositoryFactoryTest.xml
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/test/resources/org/apache/archiva/repository/DefaultRepositoryFactoryTest.xml?rev=745335&view=auto
==============================================================================
--- archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/test/resources/org/apache/archiva/repository/DefaultRepositoryFactoryTest.xml (added)
+++ archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/test/resources/org/apache/archiva/repository/DefaultRepositoryFactoryTest.xml Wed Feb 18 00:55:30 2009
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ ~ 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.
+ -->
+
+<plexus>
+ <components>
+ <!--
+ | Logger manager
+ <component>
+ <role>org.codehaus.plexus.logging.LoggerManager</role>
+ <implementation>org.codehaus.plexus.logging.slf4j.Slf4jLoggerManager</implementation>
+ <lifecycle-handler>basic</lifecycle-handler>
+ </component>
+ -->
+
+ <!--
+ | Configuration
+ -->
+ <component>
+ <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
+ <implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.registry.Registry</role>
+ <role-hint>configured</role-hint>
+ </requirement>
+ <requirement>
+ <role>org.apache.maven.archiva.policies.PreDownloadPolicy</role>
+ <field-name>prePolicies</field-name>
+ </requirement>
+ <requirement>
+ <role>org.apache.maven.archiva.policies.PostDownloadPolicy</role>
+ <field-name>postPolicies</field-name>
+ </requirement>
+ </requirements>
+ </component>
+ <component>
+ <role>org.codehaus.plexus.registry.Registry</role>
+ <role-hint>configured</role-hint>
+ <implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation>
+ <configuration>
+ <properties>
+ <system/>
+ <xml fileName="${appserver.base}/conf/archiva.xml"
+ config-name="org.apache.maven.archiva.base" config-at="org.apache.maven.archiva"/>
+ </properties>
+ </configuration>
+ </component>
+
+ <component>
+ <role>org.codehaus.plexus.cache.Cache</role>
+ <role-hint>url-failures-cache</role-hint>
+ <implementation>org.codehaus.plexus.cache.ehcache.EhcacheCache</implementation>
+ <description>URL Failure Cache</description>
+ <configuration>
+ <disk-expiry-thread-interval-seconds>600</disk-expiry-thread-interval-seconds>
+ <disk-persistent>false</disk-persistent> <!--disabling disk persistence for unit testing. -->
+ <disk-store-path>${java.io.tmpdir}/archiva/urlcache</disk-store-path>
+ <eternal>false</eternal>
+ <max-elements-in-memory>1000</max-elements-in-memory>
+ <memory-eviction-policy>LRU</memory-eviction-policy>
+ <name>url-failures-cache</name>
+ <overflow-to-disk>false</overflow-to-disk>
+ <!-- 45 minutes = 2700 seconds -->
+ <time-to-idle-seconds>2700</time-to-idle-seconds>
+ <!-- 30 minutes = 1800 seconds -->
+ <time-to-live-seconds>1800</time-to-live-seconds>
+ </configuration>
+ </component>
+
+ </components>
+</plexus>
Added: archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/test/resources/repository-archiva.xml
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/test/resources/repository-archiva.xml?rev=745335&view=auto
==============================================================================
--- archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/test/resources/repository-archiva.xml (added)
+++ archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/archiva-repository/src/test/resources/repository-archiva.xml Wed Feb 18 00:55:30 2009
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ ~ 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.
+ -->
+
+<configuration>
+
+ <version>2</version>
+
+ <repositoryScanning>
+ <fileTypes>
+ <fileType>
+ <id>artifacts</id>
+ <patterns>
+ <pattern>**/*.pom</pattern>
+ <pattern>**/*.jar</pattern>
+ <pattern>**/*.ear</pattern>
+ <pattern>**/*.war</pattern>
+ <pattern>**/*.car</pattern>
+ <pattern>**/*.sar</pattern>
+ <pattern>**/*.mar</pattern>
+ <pattern>**/*.rar</pattern>
+ <pattern>**/*.dtd</pattern>
+ <pattern>**/*.tld</pattern>
+ <pattern>**/*.tar.gz</pattern>
+ <pattern>**/*.tar.bz2</pattern>
+ <pattern>**/*.zip</pattern>
+ </patterns>
+ </fileType>
+ <fileType>
+ <id>indexable-content</id>
+ <patterns>
+ <pattern>**/*.txt</pattern>
+ <pattern>**/*.TXT</pattern>
+ <pattern>**/*.block</pattern>
+ <pattern>**/*.config</pattern>
+ <pattern>**/*.pom</pattern>
+ <pattern>**/*.xml</pattern>
+ <pattern>**/*.xsd</pattern>
+ <pattern>**/*.dtd</pattern>
+ <pattern>**/*.tld</pattern>
+ </patterns>
+ </fileType>
+ <fileType>
+ <id>auto-remove</id>
+ <patterns>
+ <pattern>**/*.bak</pattern>
+ <pattern>**/*~</pattern>
+ <pattern>**/*-</pattern>
+ </patterns>
+ </fileType>
+ <fileType>
+ <id>ignored</id>
+ <patterns>
+ <pattern>**/.htaccess</pattern>
+ <pattern>**/KEYS</pattern>
+ <pattern>**/*.rb</pattern>
+ <pattern>**/*.sh</pattern>
+ <pattern>**/.svn/**</pattern>
+ <pattern>**/.DAV/**</pattern>
+ </patterns>
+ </fileType>
+ </fileTypes>
+ <knownContentConsumers>
+ <knownContentConsumer>update-db-artifact</knownContentConsumer>
+ <knownContentConsumer>create-missing-checksums</knownContentConsumer>
+ <knownContentConsumer>update-db-repository-metadata</knownContentConsumer>
+ <knownContentConsumer>validate-checksum</knownContentConsumer>
+ <knownContentConsumer>validate-signature</knownContentConsumer>
+ <knownContentConsumer>index-content</knownContentConsumer>
+ <knownContentConsumer>auto-remove</knownContentConsumer>
+ <knownContentConsumer>auto-rename</knownContentConsumer>
+ </knownContentConsumers>
+ <invalidContentConsumers>
+ <invalidContentConsumer>update-db-bad-content</invalidContentConsumer>
+ </invalidContentConsumers>
+ </repositoryScanning>
+
+ <databaseScanning>
+ <cronExpression>0 0 * * * ?</cronExpression>
+ <unprocessedConsumers>
+ <unprocessedConsumer>index-artifact</unprocessedConsumer>
+ <unprocessedConsumer>update-db-project</unprocessedConsumer>
+ <unprocessedConsumer>validate-repository-metadata</unprocessedConsumer>
+ <unprocessedConsumer>index-archive-toc</unprocessedConsumer>
+ <unprocessedConsumer>update-db-bytecode-stats</unprocessedConsumer>
+ <unprocessedConsumer>index-public-methods</unprocessedConsumer>
+ </unprocessedConsumers>
+ <cleanupConsumers>
+ <cleanupConsumer>not-present-remove-db-artifact</cleanupConsumer>
+ <cleanupConsumer>not-present-remove-db-project</cleanupConsumer>
+ <cleanupConsumer>not-present-remove-indexed</cleanupConsumer>
+ </cleanupConsumers>
+ </databaseScanning>
+
+</configuration>
Modified: archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/pom.xml
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/pom.xml?rev=745335&r1=745334&r2=745335&view=diff
==============================================================================
--- archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/pom.xml (original)
+++ archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-base/pom.xml Wed Feb 18 00:55:30 2009
@@ -40,7 +40,8 @@
<module>archiva-transaction</module>
<module>archiva-artifact-converter</module>
<module>archiva-converter</module>
- <module>archiva-repository-api</module>
+ <module>archiva-repository-api</module>
<module>archiva-repository</module>
+ <module>archiva-event</module>
</modules>
-</project>
\ No newline at end of file
+</project>
Modified: archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-web/archiva-repository-servlet/src/test/java/org/apache/archiva/web/servlet/AbstractRepositoryServletTestCase.java
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-web/archiva-repository-servlet/src/test/java/org/apache/archiva/web/servlet/AbstractRepositoryServletTestCase.java?rev=745335&r1=745334&r2=745335&view=diff
==============================================================================
--- archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-web/archiva-repository-servlet/src/test/java/org/apache/archiva/web/servlet/AbstractRepositoryServletTestCase.java (original)
+++ archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-web/archiva-repository-servlet/src/test/java/org/apache/archiva/web/servlet/AbstractRepositoryServletTestCase.java Wed Feb 18 00:55:30 2009
@@ -74,16 +74,6 @@
assertEquals( "File Contents of <" + actualFile.getAbsolutePath() + ">", expectedContents, actualContents );
}
- protected void assertRepositoryValid( RepositoryServlet servlet, String repoId )
- {
-// ManagedRepositoryConfiguration repository = servlet.getRepository( repoId );
-// assertNotNull( "Archiva Managed Repository id:<" + repoId + "> should exist.", repository );
-// File repoRoot = new File( repository.getLocation() );
-// assertTrue( "Archiva Managed Repository id:<" + repoId + "> should have a valid location on disk.", repoRoot
-// .exists()
-// && repoRoot.isDirectory() );
- }
-
protected void assertResponseOK( WebResponse response )
{
assertNotNull( "Should have recieved a response", response );
Modified: archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-web/archiva-repository-servlet/src/test/java/org/apache/archiva/web/servlet/RepositoryServletTest.java
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-web/archiva-repository-servlet/src/test/java/org/apache/archiva/web/servlet/RepositoryServletTest.java?rev=745335&r1=745334&r2=745335&view=diff
==============================================================================
--- archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-web/archiva-repository-servlet/src/test/java/org/apache/archiva/web/servlet/RepositoryServletTest.java (original)
+++ archiva/branches/archiva-with-new-repoapi/archiva-modules/archiva-web/archiva-repository-servlet/src/test/java/org/apache/archiva/web/servlet/RepositoryServletTest.java Wed Feb 18 00:55:30 2009
@@ -39,62 +39,6 @@
{
private static final String REQUEST_PATH = "http://machine.com/repository/internal/";
- private static final String NEW_REPOSITORY_ID = "new-id";
-
- private static final String NEW_REPOSITORY_NAME = "New Repository";
-
- public void testGetRepository()
- throws Exception
- {
- RepositoryServlet servlet = (RepositoryServlet) sc.newInvocation( REQUEST_PATH ).getServlet();
- assertNotNull( servlet );
-
- assertRepositoryValid( servlet, REPOID_INTERNAL );
- }
-//
-// public void testGetRepositoryAfterDelete()
-// throws Exception
-// {
-// RepositoryServlet servlet = (RepositoryServlet) sc.newInvocation( REQUEST_PATH ).getServlet();
-// assertNotNull( servlet );
-//
-// ArchivaConfiguration archivaConfiguration = servlet.getConfiguration();
-// Configuration c = archivaConfiguration.getConfiguration();
-// c.removeManagedRepository( c.findManagedRepositoryById( REPOID_INTERNAL ) );
-// saveConfiguration( archivaConfiguration );
-//
-// ManagedRepositoryConfiguration repository = servlet.getRepository( REPOID_INTERNAL );
-// assertNull( repository );
-// }
-//
-// public void testGetRepositoryAfterAdd()
-// throws Exception
-// {
-// RepositoryServlet servlet = (RepositoryServlet) sc.newInvocation( REQUEST_PATH ).getServlet();
-// assertNotNull( servlet );
-//
-// ArchivaConfiguration archivaConfiguration = servlet.getConfiguration();
-// Configuration c = archivaConfiguration.getConfiguration();
-// ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
-// repo.setId( NEW_REPOSITORY_ID );
-// repo.setName( NEW_REPOSITORY_NAME );
-// File repoRoot = new File( getBasedir(), "target/test-repository-root" );
-// if ( !repoRoot.exists() )
-// {
-// repoRoot.mkdirs();
-// }
-// repo.setLocation( repoRoot.getAbsolutePath() );
-// c.addManagedRepository( repo );
-// saveConfiguration( archivaConfiguration );
-//
-// ManagedRepositoryConfiguration repository = servlet.getRepository( NEW_REPOSITORY_ID );
-// assertNotNull( repository );
-// assertEquals( NEW_REPOSITORY_NAME, repository.getName() );
-//
-// // check other is still intact
-// assertRepositoryValid( servlet, REPOID_INTERNAL );
-// }
-
public void testGetRepositoryInvalidPathPassthroughPresent()
throws Exception
{
@@ -116,6 +60,6 @@
WebRequest request = new GetMethodWebRequest( path );
WebResponse response = sc.getResponse( request );
assertResponseNotFound( response );
- assertEquals( "Invalid path to Artifact: legacy paths should have an expected type ending in [s] in the second part of the path.", response.getResponseMessage() );
+ assertEquals( "Could not find /internal/.index/filecontent/foo.bar", response.getResponseMessage() );
}
}
Modified: archiva/branches/archiva-with-new-repoapi/pom.xml
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-with-new-repoapi/pom.xml?rev=745335&r1=745334&r2=745335&view=diff
==============================================================================
--- archiva/branches/archiva-with-new-repoapi/pom.xml (original)
+++ archiva/branches/archiva-with-new-repoapi/pom.xml Wed Feb 18 00:55:30 2009
@@ -312,6 +312,11 @@
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-event</artifactId>
+ <version>1.2-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
<artifactId>archiva-configuration</artifactId>
<version>1.2-SNAPSHOT</version>
</dependency>