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.IMocksControl;
29 import org.springframework.stereotype.Service;
31 import java.util.HashSet;
34 import static org.easymock.EasyMock.createNiceControl;
41 @Service("archivaConfiguration#mock")
42 public class MockConfiguration
43 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 IMocksControl registryControl;
53 private Registry registryMock;
55 public MockConfiguration()
57 registryControl = createNiceControl();
58 registryMock = registryControl.createMock( Registry.class );
62 public void addChangeListener( RegistryListener listener )
64 registryListeners.add( listener );
68 public Configuration getConfiguration()
74 public void save( Configuration configuration )
75 throws RegistryException
80 public void triggerChange( String name, String value )
82 for(RegistryListener listener: registryListeners)
86 listener.afterConfigurationChange( registryMock, name, value );
96 public void addListener( ConfigurationListener listener )
98 configListeners.add(listener);
102 public void removeListener( ConfigurationListener listener )
104 configListeners.remove( listener );
108 public boolean isDefaulted()