1 package org.apache.maven.archiva.repository;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
23 import org.apache.maven.archiva.configuration.Configuration;
24 import org.apache.maven.archiva.configuration.ConfigurationListener;
25 import org.codehaus.plexus.registry.Registry;
26 import org.codehaus.plexus.registry.RegistryException;
27 import org.codehaus.plexus.registry.RegistryListener;
28 import org.easymock.MockControl;
30 import java.util.ArrayList;
31 import java.util.HashSet;
32 import java.util.Iterator;
33 import java.util.List;
39 * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
42 * @plexus.component role="org.apache.maven.archiva.configuration.ArchivaConfiguration"
45 public class MockConfiguration
46 implements ArchivaConfiguration
48 private Configuration configuration = new Configuration();
50 private Set<RegistryListener> registryListeners = new HashSet<RegistryListener>();
51 private Set<ConfigurationListener> configListeners = new HashSet<ConfigurationListener>();
53 private MockControl registryControl;
55 private Registry registryMock;
57 public MockConfiguration()
59 registryControl = MockControl.createNiceControl( Registry.class );
60 registryMock = (Registry) registryControl.getMock();
63 public void addChangeListener( RegistryListener listener )
65 registryListeners.add( listener );
68 public Configuration getConfiguration()
73 public void save( Configuration configuration )
74 throws RegistryException
79 public void triggerChange( String name, String value )
81 for(RegistryListener listener: registryListeners)
85 listener.afterConfigurationChange( registryMock, name, value );
94 public void addListener( ConfigurationListener listener )
96 configListeners.add(listener);
99 public void removeListener( ConfigurationListener listener )
101 configListeners.remove( listener );