1 package org.apache.archiva.proxy;
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.configuration.FileType;
26 import org.apache.archiva.configuration.FileTypes;
27 import org.apache.archiva.configuration.RepositoryScanningConfiguration;
28 import org.apache.archiva.redback.components.registry.Registry;
29 import org.apache.archiva.redback.components.registry.RegistryException;
30 import org.apache.archiva.redback.components.registry.RegistryListener;
31 import org.easymock.EasyMock;
32 import org.easymock.IMocksControl;
33 import org.springframework.stereotype.Service;
35 import java.util.Collections;
36 import java.util.HashSet;
37 import java.util.List;
39 import javax.annotation.PostConstruct;
46 @Service( "archivaConfiguration#mock" )
47 public class MockConfiguration
48 implements ArchivaConfiguration
51 private Configuration configuration = new Configuration();
53 private Set<RegistryListener> registryListeners = new HashSet<RegistryListener>();
55 private Set<ConfigurationListener> configListeners = new HashSet<ConfigurationListener>();
57 private IMocksControl registryControl;
59 private Registry registryMock;
61 public MockConfiguration()
63 registryControl = EasyMock.createNiceControl( );
64 registryMock = registryControl.createMock( Registry.class );
68 public void initialize()
72 configuration.setRepositoryScanning( new RepositoryScanningConfiguration()
75 public List<FileType> getFileTypes()
77 FileType fileType = new FileType();
78 fileType.setId( FileTypes.ARTIFACTS );
79 fileType.setPatterns( Collections.singletonList( "**/*" ) );
80 return Collections.singletonList( fileType );
86 public void addChangeListener( org.apache.archiva.redback.components.registry.RegistryListener listener )
88 registryListeners.add( listener );
92 public void removeChangeListener( RegistryListener listener )
94 registryListeners.remove( listener );
98 public Configuration getConfiguration()
100 return configuration;
104 public void save( Configuration configuration )
105 throws RegistryException
110 public void triggerChange( String name, String value )
112 for ( org.apache.archiva.redback.components.registry.RegistryListener listener : registryListeners )
116 listener.afterConfigurationChange( registryMock, name, value );
118 catch ( Exception e )
126 public void addListener( ConfigurationListener listener )
128 configListeners.add( listener );
132 public void removeListener( ConfigurationListener listener )
134 configListeners.remove( listener );
138 public boolean isDefaulted()