1 package org.apache.archiva.metadata.repository.storage.maven2.conf;
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.archiva.configuration.ArchivaConfiguration;
23 import org.apache.archiva.configuration.Configuration;
24 import org.apache.archiva.configuration.ConfigurationListener;
25 import org.apache.archiva.redback.components.registry.Registry;
26 import org.apache.archiva.redback.components.registry.RegistryException;
27 import org.apache.archiva.redback.components.registry.RegistryListener;
28 import org.easymock.MockControl;
29 import org.springframework.stereotype.Service;
31 import java.util.HashSet;
39 @Service("archivaConfiguration#mock")
40 public class MockConfiguration
41 implements ArchivaConfiguration
44 private Configuration configuration = new Configuration();
46 private Set<RegistryListener> registryListeners = new HashSet<RegistryListener>();
47 private Set<ConfigurationListener> configListeners = new HashSet<ConfigurationListener>();
49 private MockControl registryControl;
51 private Registry registryMock;
53 public MockConfiguration()
55 registryControl = MockControl.createNiceControl( Registry.class );
56 registryMock = (Registry) registryControl.getMock();
59 public void addChangeListener( RegistryListener listener )
61 registryListeners.add( listener );
64 public Configuration getConfiguration()
69 public void save( Configuration configuration )
70 throws RegistryException
75 public void triggerChange( String name, String value )
77 for(RegistryListener listener: registryListeners)
81 listener.afterConfigurationChange( registryMock, name, value );
90 public void addListener( ConfigurationListener listener )
92 configListeners.add(listener);
95 public void removeListener( ConfigurationListener listener )
97 configListeners.remove( listener );
100 public boolean isDefaulted()