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.MockControl;
32 import org.springframework.stereotype.Service;
34 import java.util.Collections;
35 import java.util.HashSet;
36 import java.util.List;
38 import javax.annotation.PostConstruct;
45 @Service( "archivaConfiguration#mock" )
46 public class MockConfiguration
47 implements ArchivaConfiguration
50 private Configuration configuration = new Configuration();
52 private Set<RegistryListener> registryListeners = new HashSet<RegistryListener>();
54 private Set<ConfigurationListener> configListeners = new HashSet<ConfigurationListener>();
56 private MockControl registryControl;
58 private Registry registryMock;
60 public MockConfiguration()
62 registryControl = MockControl.createNiceControl( org.apache.archiva.redback.components.registry.Registry.class );
63 registryMock = (org.apache.archiva.redback.components.registry.Registry) registryControl.getMock();
67 public void initialize()
71 configuration.setRepositoryScanning( new RepositoryScanningConfiguration()
74 public List<FileType> getFileTypes()
76 FileType fileType = new FileType();
77 fileType.setId( FileTypes.ARTIFACTS );
78 fileType.setPatterns( Collections.singletonList( "**/*" ) );
79 return Collections.singletonList( fileType );
84 public void addChangeListener( org.apache.archiva.redback.components.registry.RegistryListener listener )
86 registryListeners.add( listener );
89 public Configuration getConfiguration()
94 public void save( Configuration configuration )
95 throws RegistryException
100 public void triggerChange( String name, String value )
102 for ( org.apache.archiva.redback.components.registry.RegistryListener listener : registryListeners )
106 listener.afterConfigurationChange( registryMock, name, value );
108 catch ( Exception e )
115 public void addListener( ConfigurationListener listener )
117 configListeners.add( listener );
120 public void removeListener( ConfigurationListener listener )
122 configListeners.remove( listener );
125 public boolean isDefaulted()