1 package org.apache.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.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
43 private Configuration configuration = new Configuration();
45 private Set<RegistryListener> registryListeners = new HashSet<RegistryListener>();
46 private Set<ConfigurationListener> configListeners = new HashSet<ConfigurationListener>();
48 private MockControl registryControl;
50 private Registry registryMock;
52 public MockConfiguration()
54 registryControl = MockControl.createNiceControl( Registry.class );
55 registryMock = (Registry) registryControl.getMock();
58 public void addChangeListener( RegistryListener listener )
60 registryListeners.add( listener );
63 public Configuration getConfiguration()
68 public void save( Configuration configuration )
69 throws RegistryException
74 public void triggerChange( String name, String value )
76 for(RegistryListener listener: registryListeners)
80 listener.afterConfigurationChange( registryMock, name, value );
89 public void addListener( ConfigurationListener listener )
91 configListeners.add(listener);
94 public void removeListener( ConfigurationListener listener )
96 configListeners.remove( listener );
99 public boolean isDefaulted()