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;
29 import org.springframework.stereotype.Service;
31 import java.util.HashSet;
39 * plexus.component role="org.apache.maven.archiva.configuration.ArchivaConfiguration"
42 @Service("archivaConfiguration#mock")
43 public class MockConfiguration
44 implements ArchivaConfiguration
46 private Configuration configuration = new Configuration();
48 private Set<RegistryListener> registryListeners = new HashSet<RegistryListener>();
49 private Set<ConfigurationListener> configListeners = new HashSet<ConfigurationListener>();
51 private MockControl registryControl;
53 private Registry registryMock;
55 public MockConfiguration()
57 registryControl = MockControl.createNiceControl( Registry.class );
58 registryMock = (Registry) registryControl.getMock();
61 public void addChangeListener( RegistryListener listener )
63 registryListeners.add( listener );
66 public Configuration getConfiguration()
71 public void save( Configuration configuration )
72 throws RegistryException
77 public void triggerChange( String name, String value )
79 for(RegistryListener listener: registryListeners)
83 listener.afterConfigurationChange( registryMock, name, value );
92 public void addListener( ConfigurationListener listener )
94 configListeners.add(listener);
97 public void removeListener( ConfigurationListener listener )
99 configListeners.remove( listener );
102 public boolean isDefaulted()