/**
* RepositoryServlet
- *
*/
public class RepositoryServlet
extends AbstractWebdavServlet
/**
* Service the given request. This method has been overridden and copy/pasted to allow better exception handling and
* to support different realms
- *
+ *
* @param request
* @param response
* @throws ServletException
WebdavRequest webdavRequest = new WebdavRequestImpl( request, getLocatorFactory() );
// DeltaV requires 'Cache-Control' header for all methods except 'VERSION-CONTROL' and 'REPORT'.
int methodCode = DavMethods.getMethodCode( request.getMethod() );
- boolean noCache =
- DavMethods.isDeltaVMethod( webdavRequest )
- && !( DavMethods.DAV_VERSION_CONTROL == methodCode || DavMethods.DAV_REPORT == methodCode );
+ boolean noCache = DavMethods.isDeltaVMethod( webdavRequest ) && !( DavMethods.DAV_VERSION_CONTROL == methodCode
+ || DavMethods.DAV_REPORT == methodCode );
WebdavResponse webdavResponse = new WebdavResponseImpl( response, noCache );
DavResource resource = null;
}
}
- resourceFactory = wac.getBean (DavResourceFactory.class);
+ resourceFactory = wac.getBean("davResourceFactory#archiva", DavResourceFactory.class );
locatorFactory = new ArchivaDavLocatorFactory();
ServletAuthenticator servletAuth = wac.getBean( ServletAuthenticator.class );
public void destroy()
{
configuration.removeListener( this );
-
+
resourceFactory = null;
configuration = null;
locatorFactory = null;
sessionProvider = null;
repositoryMap.clear();
repositoryMap = null;
-
+
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext( getServletContext() );
if ( wac instanceof ConfigurableApplicationContext )
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
private ServletRunner sr;
- @Inject
protected ArchivaConfiguration archivaConfiguration;
private DavSessionProvider davSessionProvider;
private RepositoryServlet servlet;
+ @Inject
+ ApplicationContext applicationContext;
+
@Before
public void setUp()
throws Exception
{
super.setUp();
- String appserverBase = new File( "target/appserver-base" ).getAbsolutePath();
- System.setProperty( "appserver.base", appserverBase );
+ String appserverBase = System.getProperty( "appserver.base", new File( "target/appserver-base" ).getAbsolutePath() );
File testConf = new File( "src/test/resources/repository-archiva.xml" );
File testConfDest = new File( appserverBase, "conf/archiva.xml" );
FileUtils.copyFile( testConf, testConfDest );
repoRootInternal = new File( appserverBase, "data/repositories/internal" );
+
+ archivaConfiguration = applicationContext.getBean( ArchivaConfiguration.class );
Configuration config = archivaConfiguration.getConfiguration();
- config.addManagedRepository( createManagedRepository( REPOID_INTERNAL, "Internal Test Repo", repoRootInternal ) );
+ if (!config.getManagedRepositoriesAsMap().containsKey( REPOID_INTERNAL ))
+ {
+ config.addManagedRepository( createManagedRepository( REPOID_INTERNAL, "Internal Test Repo", repoRootInternal ) );
+ }
saveConfiguration( archivaConfiguration );
- CacheManager.getInstance().removeCache( "url-failures-cache" );
+ CacheManager.getInstance().clearAll();
HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );
<param-name>contextConfigLocation</param-name>
<param-value>
classpath*:/META-INF/spring-context.xml
- classpath*:/spring-context.xml
+ classpath*:/spring-context-servlet-security-test.xml
</param-value>
</context-param>
--- /dev/null
+<?xml version="1.0"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd"
+ default-lazy-init="true">
+
+ <context:property-placeholder system-properties-mode="OVERRIDE"/>
+
+ <context:annotation-config/>
+ <context:component-scan base-package="org.apache.maven.archiva.webdav,org.apache.archiva.metadata.repository"/>
+
+ <bean name="scheduler" class="org.codehaus.redback.components.scheduler.DefaultScheduler">
+ <property name="properties">
+ <props>
+ <prop key="org.quartz.scheduler.instanceName">scheduler1</prop>
+ <prop key="org.quartz.threadPool.class">org.quartz.simpl.SimpleThreadPool</prop>
+ <prop key="org.quartz.threadPool.threadCount">1</prop>
+ <prop key="org.quartz.threadPool.threadPriority">4</prop>
+ <prop key="org.quartz.jobStore.class">org.quartz.simpl.RAMJobStore</prop>
+ </props>
+ </property>
+ </bean>
+
+ <bean name="servletAuthenticator" class="org.apache.maven.archiva.webdav.MockServletAuthenticator"/>
+
+ <bean name="archivaConfiguration#default" class="org.apache.maven.archiva.configuration.DefaultArchivaConfiguration">
+ <property name="registry" ref="registry#default"/>
+ </bean>
+
+ <alias name="archivaConfiguration#default" alias="archivaConfiguration"/>
+
+ <bean name="registry#default" class="org.codehaus.redback.components.registry.commons.CommonsConfigurationRegistry">
+ <property name="properties">
+ <value>
+ <![CDATA[
+ <configuration>
+ <system/>
+ <xml fileName="${appserver.base}/conf/archiva.xml" config-forceCreate="true"
+ config-optional="true"
+ config-name="org.apache.maven.archiva.base" config-at="org.apache.maven.archiva"/>
+ </configuration>
+ ]]>
+ </value>
+ </property>
+ </bean>
+ <!--
+ <bean name="davResourceFactory#archiva" class="org.apache.maven.archiva.webdav.UnauthenticatedDavResourceFactory">
+ <property name="servletAuth" ref="servletAuthenticator"/>
+ </bean>
+ -->
+
+</beans>
\ No newline at end of file