From 8d6a0c0a714ddc61ce5a3121a1ccbb8149c5b17c Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Thu, 13 Sep 2012 11:34:33 +0000 Subject: better place for those tests which are not specific to the ui implementation (not sure we will change soon again but that's better :-)) git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1384280 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva-web/archiva-web-common/pom.xml | 84 +++++++ .../org/apache/archiva/AbstractDownloadTest.java | 278 +++++++++++++++++++++ .../org/apache/archiva/DownloadArtifactsTest.java | 240 ++++++++++++++++++ .../apache/archiva/DownloadMergedIndexTest.java | 183 ++++++++++++++ .../archiva-web-common/src/test/junit-4.9.jar | Bin 0 -> 248994 bytes .../1.0/archiva-search-1.0-patch1.jar | Bin 0 -> 2518 bytes .../1.0/archiva-search-1.0-sources.jar | Bin 0 -> 2518 bytes .../archiva-search/1.0/archiva-search-1.0.jar | Bin 0 -> 2518 bytes .../archiva-search/1.0/archiva-search-1.0.pom | 28 +++ .../archiva/archiva-test/1.0/archiva-test-1.0.jar | Bin 0 -> 2471 bytes .../archiva/archiva-test/1.0/archiva-test-1.0.pom | 23 ++ .../archiva/archiva-test/2.0/archiva-test-2.0.jar | Bin 0 -> 2494 bytes .../archiva/archiva-test/2.0/archiva-test-2.0.pom | 28 +++ .../archiva-webapp/1.0/archiva-webapp-1.0.pom | 23 ++ .../archiva-webapp/1.0/archiva-webapp-1.0.war | 0 .../1.0-SNAPSHOT/test-webapp-1.0-SNAPSHOT.war | Bin 0 -> 4169 bytes .../org.apache.felix.bundlerepository-1.6.6.jar | Bin 0 -> 168279 bytes .../org.apache.felix.bundlerepository-1.6.6.pom | 138 ++++++++++ .../archiva-web-common/src/test/repository.xml | 49 ++++ .../src/test/resources/META-INF/spring-context.xml | 87 +++++++ .../spring-context-artifacts-download.xml | 55 ++++ .../spring-context-merge-index-download.xml | 56 +++++ .../archiva-web/archiva-webapp-js/pom.xml | 18 -- .../org/apache/archiva/AbstractDownloadTest.java | 278 --------------------- .../org/apache/archiva/DownloadArtifactsTest.java | 240 ------------------ .../apache/archiva/DownloadMergedIndexTest.java | 183 -------------- .../1.0/archiva-search-1.0-patch1.jar | Bin 2518 -> 0 bytes .../1.0/archiva-search-1.0-sources.jar | Bin 2518 -> 0 bytes .../archiva-search/1.0/archiva-search-1.0.jar | Bin 2518 -> 0 bytes .../archiva-search/1.0/archiva-search-1.0.pom | 28 --- .../archiva/archiva-test/1.0/archiva-test-1.0.jar | Bin 2471 -> 0 bytes .../archiva/archiva-test/1.0/archiva-test-1.0.pom | 23 -- .../archiva/archiva-test/2.0/archiva-test-2.0.jar | Bin 2494 -> 0 bytes .../archiva/archiva-test/2.0/archiva-test-2.0.pom | 28 --- .../archiva-webapp/1.0/archiva-webapp-1.0.pom | 23 -- .../archiva-webapp/1.0/archiva-webapp-1.0.war | 0 .../1.0-SNAPSHOT/test-webapp-1.0-SNAPSHOT.war | Bin 4169 -> 0 bytes .../org.apache.felix.bundlerepository-1.6.6.jar | Bin 168279 -> 0 bytes .../org.apache.felix.bundlerepository-1.6.6.pom | 138 ---------- .../spring-context-artifacts-download.xml | 55 ---- .../spring-context-merge-index-download.xml | 56 ----- 41 files changed, 1272 insertions(+), 1070 deletions(-) create mode 100644 archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/AbstractDownloadTest.java create mode 100644 archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/DownloadArtifactsTest.java create mode 100644 archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/DownloadMergedIndexTest.java create mode 100644 archiva-modules/archiva-web/archiva-web-common/src/test/junit-4.9.jar create mode 100644 archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0-patch1.jar create mode 100644 archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0-sources.jar create mode 100644 archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar create mode 100644 archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.pom create mode 100644 archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar create mode 100644 archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom create mode 100644 archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.jar create mode 100644 archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.pom create mode 100644 archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-webapp/1.0/archiva-webapp-1.0.pom create mode 100644 archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-webapp/1.0/archiva-webapp-1.0.war create mode 100644 archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/test-webapp/1.0-SNAPSHOT/test-webapp-1.0-SNAPSHOT.war create mode 100644 archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.jar create mode 100644 archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.pom create mode 100644 archiva-modules/archiva-web/archiva-web-common/src/test/repository.xml create mode 100644 archiva-modules/archiva-web/archiva-web-common/src/test/resources/META-INF/spring-context.xml create mode 100644 archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-artifacts-download.xml create mode 100644 archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-merge-index-download.xml delete mode 100644 archiva-modules/archiva-web/archiva-webapp-js/src/test/java/org/apache/archiva/AbstractDownloadTest.java delete mode 100644 archiva-modules/archiva-web/archiva-webapp-js/src/test/java/org/apache/archiva/DownloadArtifactsTest.java delete mode 100644 archiva-modules/archiva-web/archiva-webapp-js/src/test/java/org/apache/archiva/DownloadMergedIndexTest.java delete mode 100644 archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0-patch1.jar delete mode 100644 archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0-sources.jar delete mode 100644 archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar delete mode 100644 archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.pom delete mode 100644 archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar delete mode 100644 archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom delete mode 100644 archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.jar delete mode 100644 archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.pom delete mode 100644 archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-webapp/1.0/archiva-webapp-1.0.pom delete mode 100644 archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-webapp/1.0/archiva-webapp-1.0.war delete mode 100644 archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/test-webapp/1.0-SNAPSHOT/test-webapp-1.0-SNAPSHOT.war delete mode 100644 archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.jar delete mode 100644 archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.pom delete mode 100644 archiva-modules/archiva-web/archiva-webapp-js/src/test/resources/spring-context-artifacts-download.xml delete mode 100644 archiva-modules/archiva-web/archiva-webapp-js/src/test/resources/spring-context-merge-index-download.xml diff --git a/archiva-modules/archiva-web/archiva-web-common/pom.xml b/archiva-modules/archiva-web/archiva-web-common/pom.xml index ac2288a69..c6d269acd 100644 --- a/archiva-modules/archiva-web/archiva-web-common/pom.xml +++ b/archiva-modules/archiva-web/archiva-web-common/pom.xml @@ -172,6 +172,77 @@ wagon-http-lightweight test + + + org.eclipse.jetty + jetty-server + test + + + org.eclipse.jetty + jetty-plus + test + + + + org.apache.commons + commons-compress + test + + + + org.apache.archiva.redback + redback-rest-services + tests + test + + + + org.apache.archiva.redback + redback-rest-services + test + + + + org.apache.archiva + archiva-rest-services + test + + + + org.apache.archiva + archiva-webdav + test + + + + org.apache.archiva + archiva-repository-admin-default + test + + + + org.apache.archiva + metadata-store-jcr + test + + + + org.apache.jackrabbit + jackrabbit-core + test + + + commons-logging + commons-logging + + + org.slf4j + jcl-over-slf4j + + + + @@ -184,6 +255,19 @@ true + + + + org.apache.rat + apache-rat-plugin + + + src/test/repositories/test-repo/** + + + + + org.apache.felix diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/AbstractDownloadTest.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/AbstractDownloadTest.java new file mode 100644 index 000000000..fdf51e81b --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/AbstractDownloadTest.java @@ -0,0 +1,278 @@ +package org.apache.archiva; +/* + * 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. + */ + +import junit.framework.TestCase; +import org.apache.archiva.rest.api.services.ManagedRepositoriesService; +import org.apache.archiva.rest.api.services.ProxyConnectorService; +import org.apache.archiva.rest.api.services.RemoteRepositoriesService; +import org.apache.archiva.rest.api.services.RepositoriesService; +import org.apache.archiva.rest.api.services.RepositoryGroupService; +import org.apache.archiva.rest.api.services.SearchService; +import org.apache.archiva.webdav.RepositoryServlet; +import org.apache.commons.lang.StringUtils; +import org.apache.cxf.common.util.Base64Utility; +import org.apache.cxf.jaxrs.client.JAXRSClientFactory; +import org.apache.cxf.jaxrs.client.WebClient; +import org.apache.cxf.transport.servlet.CXFServlet; +import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider; +import org.apache.archiva.redback.integration.security.role.RedbackRoleConstants; +import org.apache.archiva.redback.rest.api.model.User; +import org.apache.archiva.redback.rest.api.services.RoleManagementService; +import org.apache.archiva.redback.rest.api.services.UserService; +import org.apache.archiva.redback.rest.services.FakeCreateAdminService; +import org.eclipse.jetty.server.Connector; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.session.SessionHandler; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.servlet.ServletHolder; +import org.junit.After; +import org.junit.Before; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.context.ContextLoaderListener; + +import java.util.Collections; +import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner; +import org.junit.runner.RunWith; + +/** + * @author Olivier Lamy + */ +@RunWith( ArchivaBlockJUnit4ClassRunner.class ) +public abstract class AbstractDownloadTest + extends TestCase +{ + + protected Logger log = LoggerFactory.getLogger( getClass() ); + + static String previousAppServerBase; + + public String authorizationHeader = getAdminAuthzHeader(); + + public Server server = null; + + public int port; + + public static String encode( String uid, String password ) + { + return "Basic " + Base64Utility.encode( ( uid + ":" + password ).getBytes() ); + } + + public static String getAdminAuthzHeader() + { + String adminPwdSysProps = System.getProperty( "rest.admin.pwd" ); + if ( StringUtils.isBlank( adminPwdSysProps ) ) + { + return encode( RedbackRoleConstants.ADMINISTRATOR_ACCOUNT_NAME, FakeCreateAdminService.ADMIN_TEST_PWD ); + } + return encode( RedbackRoleConstants.ADMINISTRATOR_ACCOUNT_NAME, adminPwdSysProps ); + } + + + protected abstract String getSpringConfigLocation(); + + + protected String getRestServicesPath() + { + return "restServices"; + } + + + @Before + public void startServer() + throws Exception + { + + System.setProperty( "redback.admin.creation.file", "target/auto-admin-creation.properties" ); + this.server = new Server( 0 ); + + ServletContextHandler context = new ServletContextHandler(); + + context.setContextPath( "/" ); + + context.setInitParameter( "contextConfigLocation", getSpringConfigLocation() ); + + ContextLoaderListener contextLoaderListener = new ContextLoaderListener(); + + context.addEventListener( contextLoaderListener ); + + ServletHolder sh = new ServletHolder( CXFServlet.class ); + + SessionHandler sessionHandler = new SessionHandler(); + + context.setSessionHandler( sessionHandler ); + + context.addServlet( sh, "/" + getRestServicesPath() + "/*" ); + + ServletHolder repoSh = new ServletHolder( RepositoryServlet.class ); + context.addServlet( repoSh, "/repository/*" ); + + server.setHandler( context ); + this.server.start(); + Connector connector = this.server.getConnectors()[0]; + this.port = connector.getLocalPort(); + log.info( "start server on port " + this.port ); + + User user = new User(); + user.setEmail( "toto@toto.fr" ); + user.setFullName( "the root user" ); + user.setUsername( RedbackRoleConstants.ADMINISTRATOR_ACCOUNT_NAME ); + user.setPassword( FakeCreateAdminService.ADMIN_TEST_PWD ); + + getUserService( null ).createAdminUser( user ); + + + } + + + @After + public void tearDown() + throws Exception + { + System.clearProperty( "redback.admin.creation.file" ); + super.tearDown(); + if ( this.server != null ) + { + this.server.stop(); + } + } + + + protected ProxyConnectorService getProxyConnectorService() + { + ProxyConnectorService service = + JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", + ProxyConnectorService.class, + Collections.singletonList( new JacksonJaxbJsonProvider() ) ); + + WebClient.client( service ).header( "Authorization", authorizationHeader ); + WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000L ); + return service; + } + + protected RemoteRepositoriesService getRemoteRepositoriesService() + { + RemoteRepositoriesService service = + JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", + RemoteRepositoriesService.class, + Collections.singletonList( new JacksonJaxbJsonProvider() ) ); + + WebClient.client( service ).header( "Authorization", authorizationHeader ); + WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000L ); + return service; + } + + protected ManagedRepositoriesService getManagedRepositoriesService() + { + ManagedRepositoriesService service = + JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", + ManagedRepositoriesService.class, + Collections.singletonList( new JacksonJaxbJsonProvider() ) ); + + WebClient.client( service ).header( "Authorization", authorizationHeader ); + WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000L ); + return service; + } + + + protected RepositoryGroupService getRepositoryGroupService() + { + RepositoryGroupService service = + JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", + RepositoryGroupService.class, + Collections.singletonList( new JacksonJaxbJsonProvider() ) ); + + WebClient.client( service ).header( "Authorization", authorizationHeader ); + WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000L ); + return service; + } + + protected RepositoriesService getRepositoriesService() + { + RepositoriesService service = + JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", + RepositoriesService.class, + Collections.singletonList( new JacksonJaxbJsonProvider() ) ); + + WebClient.client( service ).header( "Authorization", authorizationHeader ); + WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000L ); + return service; + } + + protected SearchService getSearchService() + { + SearchService service = + JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", + SearchService.class, + Collections.singletonList( new JacksonJaxbJsonProvider() ) ); + + WebClient.client( service ).header( "Authorization", authorizationHeader ); + WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000L ); + return service; + } + + protected String getBaseUrl() + { + String baseUrlSysProps = System.getProperty( "archiva.baseRestUrl" ); + return StringUtils.isBlank( baseUrlSysProps ) ? "http://localhost:" + port : baseUrlSysProps; + } + + + protected RoleManagementService getRoleManagementService( String authzHeader ) + { + RoleManagementService service = + JAXRSClientFactory.create( "http://localhost:" + port + "/" + getRestServicesPath() + "/redbackServices/", + RoleManagementService.class, + Collections.singletonList( new JacksonJaxbJsonProvider() ) ); + + // for debuging purpose + WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 3000000L ); + + if ( authzHeader != null ) + { + WebClient.client( service ).header( "Authorization", authzHeader ); + } + return service; + } + + protected UserService getUserService( String authzHeader ) + { + UserService service = + JAXRSClientFactory.create( "http://localhost:" + port + "/" + getRestServicesPath() + "/redbackServices/", + UserService.class, Collections.singletonList( new JacksonJaxbJsonProvider() ) ); + + // for debuging purpose + WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 3000000L ); + + if ( authzHeader != null ) + { + WebClient.client( service ).header( "Authorization", authzHeader ); + } + return service; + } + + protected FakeCreateAdminService getFakeCreateAdminService() + { + return JAXRSClientFactory.create( + "http://localhost:" + port + "/" + getRestServicesPath() + "/fakeCreateAdminService/", + FakeCreateAdminService.class ); + } + +} diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/DownloadArtifactsTest.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/DownloadArtifactsTest.java new file mode 100644 index 000000000..ff1c7322e --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/DownloadArtifactsTest.java @@ -0,0 +1,240 @@ +package org.apache.archiva; +/* + * 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. + */ + +import org.apache.archiva.admin.model.beans.RemoteRepository; +import org.apache.archiva.redback.rest.api.services.RoleManagementService; +import org.apache.archiva.security.common.ArchivaRoleConstants; +import org.apache.commons.compress.utils.IOUtils; +import org.apache.commons.io.FileUtils; +import org.apache.maven.wagon.providers.http.HttpWagon; +import org.apache.maven.wagon.repository.Repository; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.servlet.ServletHolder; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Enumeration; +import java.util.List; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; +import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner; + +/** + * @author Olivier Lamy + */ +@RunWith( ArchivaBlockJUnit4ClassRunner.class ) +public class DownloadArtifactsTest + extends AbstractDownloadTest +{ + + protected Logger log = LoggerFactory.getLogger( DownloadArtifactsTest.class ); + + public Server redirectServer = null; + + public int redirectPort; + + public Server repoServer = null; + + public int repoServerPort; + + @BeforeClass + public static void setAppServerBase() + { + previousAppServerBase = System.getProperty( "appserver.base" ); + System.setProperty( "appserver.base", "target/" + DownloadArtifactsTest.class.getName() ); + } + + + @AfterClass + public static void resetAppServerBase() + { + System.setProperty( "appserver.base", previousAppServerBase ); + } + + protected String getSpringConfigLocation() + { + return "classpath*:META-INF/spring-context.xml classpath*:spring-context-artifacts-download.xml"; + } + + @Before + public void startServer() + throws Exception + { + super.startServer(); + + // repo handler + + this.repoServer = new Server( 0 ); + + ServletHolder shRepo = new ServletHolder( RepoServlet.class ); + ServletContextHandler contextRepo = new ServletContextHandler(); + + contextRepo.setContextPath( "/" ); + contextRepo.addServlet( shRepo, "/*" ); + + repoServer.setHandler( contextRepo ); + repoServer.start(); + this.repoServerPort = repoServer.getConnectors()[0].getLocalPort(); + + //redirect handler + + this.redirectServer = new Server( 0 ); + ServletHolder shRedirect = new ServletHolder( RedirectServlet.class ); + ServletContextHandler contextRedirect = new ServletContextHandler(); + contextRedirect.setAttribute( "redirectToPort", Integer.toString( this.repoServerPort ) ); + + contextRedirect.setContextPath( "/" ); + contextRedirect.addServlet( shRedirect, "/*" ); + + redirectServer.setHandler( contextRedirect ); + redirectServer.start(); + this.redirectPort = redirectServer.getConnectors()[0].getLocalPort(); + log.info( "redirect server port {}", redirectPort ); + + + + } + + @After + public void tearDown() + throws Exception + { + super.tearDown(); + if ( this.redirectServer != null ) + { + this.redirectServer.stop(); + } + } + + @Test + public void downloadWithRemoteRedirect() + throws Exception + { + RemoteRepository remoteRepository = getRemoteRepositoriesService().getRemoteRepository( "central" ); + remoteRepository.setUrl( "http://localhost:" + redirectPort ); + getRemoteRepositoriesService().updateRemoteRepository( remoteRepository ); + + RoleManagementService roleManagementService = getRoleManagementService( authorizationHeader ); + + if ( !roleManagementService.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, + "internal" ) ) + { + roleManagementService.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, "internal" ); + } + + getUserService( authorizationHeader ).createGuestUser(); + roleManagementService.assignRole( ArchivaRoleConstants.TEMPLATE_GUEST, "guest" ); + + roleManagementService.assignTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, "internal", + "guest" ); + + getUserService( authorizationHeader ).removeFromCache( "guest" ); + + File file = new File( "target/junit-4.9.jar" ); + if ( file.exists() ) + { + file.delete(); + } + + HttpWagon httpWagon = new HttpWagon(); + httpWagon.connect( new Repository( "foo", "http://localhost:" + port ) ); + + httpWagon.get( "/repository/internal/junit/junit/4.9/junit-4.9.jar", file ); + + ZipFile zipFile = new ZipFile( file ); + List entries = getZipEntriesNames( zipFile ); + ZipEntry zipEntry = zipFile.getEntry( "org/junit/runners/JUnit4.class" ); + assertNotNull( "cannot find zipEntry org/junit/runners/JUnit4.class, entries: " + entries + ", content is: " + + FileUtils.readFileToString( file ), zipEntry ); + zipFile.close(); + file.deleteOnExit(); + } + + private List getZipEntriesNames( ZipFile zipFile ) + { + try + { + List entriesNames = new ArrayList(); + Enumeration entries = zipFile.entries(); + while ( entries.hasMoreElements() ) + { + entriesNames.add( entries.nextElement().getName() ); + } + return entriesNames; + } + catch ( Throwable e ) + { + log.info( "fail to get zipEntries " + e.getMessage(), e ); + } + return Collections.emptyList(); + } + + + public static class RedirectServlet + extends HttpServlet + { + @Override + protected void doGet( HttpServletRequest req, HttpServletResponse resp ) + throws ServletException, IOException + { + + LoggerFactory.getLogger( getClass() ).info( "redirect servlet receive: {}", req.getRequestURI() ); + resp.setStatus( 302 ); + resp.getWriter().write( "\n" + "\n" + + "302 Found\n" + "\n" + "

Found

\n" + + "

The document has moved here.

\n" + + "\n" + "\n" + + "\n" ); + resp.sendRedirect( "http://localhost:" + getServletContext().getAttribute( "redirectToPort" ) + "/maven2/" + + req.getRequestURI() ); + } + } + + public static class RepoServlet + extends HttpServlet + { + @Override + protected void doGet( HttpServletRequest req, HttpServletResponse resp ) + throws ServletException, IOException + { + File jar = new File( System.getProperty( "basedir" ), "src/test/junit-4.9.jar" ); + IOUtils.copy( new FileInputStream( jar ), resp.getOutputStream() ); + + } + } + + +} diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/DownloadMergedIndexTest.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/DownloadMergedIndexTest.java new file mode 100644 index 000000000..118ff0dc8 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/DownloadMergedIndexTest.java @@ -0,0 +1,183 @@ +package org.apache.archiva; +/* + * 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. + */ + +import org.apache.archiva.admin.model.beans.ManagedRepository; +import org.apache.archiva.admin.model.beans.ProxyConnector; +import org.apache.archiva.admin.model.beans.RemoteRepository; +import org.apache.archiva.admin.model.beans.RepositoryGroup; +import org.apache.archiva.maven2.model.Artifact; +import org.apache.archiva.rest.api.model.SearchRequest; +import org.apache.archiva.rest.api.services.ManagedRepositoriesService; +import org.apache.archiva.rest.api.services.ProxyConnectorService; +import org.apache.archiva.rest.api.services.RepositoriesService; +import org.apache.archiva.rest.api.services.RepositoryGroupService; +import org.apache.archiva.rest.api.services.SearchService; +import org.apache.commons.io.FileUtils; +import org.apache.archiva.redback.integration.security.role.RedbackRoleConstants; +import org.apache.archiva.redback.rest.services.FakeCreateAdminService; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.Arrays; +import java.util.List; +import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner; + +/** + * @author Olivier Lamy + */ +@RunWith( ArchivaBlockJUnit4ClassRunner.class ) +public class DownloadMergedIndexTest + extends AbstractDownloadTest +{ + + @BeforeClass + public static void setAppServerBase() + { + previousAppServerBase = System.getProperty( "appserver.base" ); + System.setProperty( "appserver.base", "target/" + DownloadMergedIndexTest.class.getName() ); + } + + @AfterClass + public static void resetAppServerBase() + { + System.setProperty( "appserver.base", previousAppServerBase ); + } + + protected String getSpringConfigLocation() + { + return "classpath*:META-INF/spring-context.xml classpath*:spring-context-merge-index-download.xml"; + } + + @After + public void cleanup() + throws Exception + { + super.tearDown(); + File tmpIndexDir = new File( System.getProperty( "java.io.tmpdir" ) + "/tmpIndex" ); + if ( tmpIndexDir.exists() ) + { + FileUtils.deleteDirectory( tmpIndexDir ); + } + } + + + @Test + public void downloadMergedIndex() + throws Exception + { + File tmpIndexDir = new File( System.getProperty( "java.io.tmpdir" ) + "/tmpIndex" ); + if ( tmpIndexDir.exists() ) + { + FileUtils.deleteDirectory( tmpIndexDir ); + } + String id = Long.toString( System.currentTimeMillis() ); + ManagedRepository managedRepository = new ManagedRepository(); + managedRepository.setId( id ); + managedRepository.setName( "name of " + id ); + managedRepository.setLocation( "src/test/repositories/test-repo" ); + managedRepository.setIndexDirectory( System.getProperty( "java.io.tmpdir" ) + "/tmpIndex/" + id ); + + ManagedRepositoriesService managedRepositoriesService = getManagedRepositoriesService(); + + if ( managedRepositoriesService.getManagedRepository( id ) != null ) + { + managedRepositoriesService.deleteManagedRepository( id, false ); + } + + getManagedRepositoriesService().addManagedRepository( managedRepository ); + + RepositoriesService repositoriesService = getRepositoriesService(); + + repositoriesService.scanRepositoryNow( id, true ); + + // wait a bit to ensure index is finished + int timeout = 20000; + while ( timeout > 0 && repositoriesService.alreadyScanning( id ) ) + { + Thread.sleep( 500 ); + timeout -= 500; + } + + RepositoryGroupService repositoryGroupService = getRepositoryGroupService(); + + RepositoryGroup repositoryGroup = new RepositoryGroup(); + repositoryGroup.setId( "test-group" ); + repositoryGroup.setRepositories( Arrays.asList( id ) ); + + repositoryGroupService.addRepositoryGroup( repositoryGroup ); + + // create a repo with a remote on the one with index + id = Long.toString( System.currentTimeMillis() ); + managedRepository = new ManagedRepository(); + managedRepository.setId( id ); + managedRepository.setName( "name of " + id ); + managedRepository.setLocation( "src/test/repositories/test-repo" ); + managedRepository.setIndexDirectory( System.getProperty( "java.io.tmpdir" ) + "/tmpIndex/" + id ); + + if ( managedRepositoriesService.getManagedRepository( id ) != null ) + { + managedRepositoriesService.deleteManagedRepository( id, false ); + } + + getManagedRepositoriesService().addManagedRepository( managedRepository ); + + RemoteRepository remoteRepository = new RemoteRepository(); + remoteRepository.setId( "all-merged" ); + remoteRepository.setName( "all-merged" ); + remoteRepository.setDownloadRemoteIndex( true ); + remoteRepository.setUrl( "http://localhost:" + port + "/repository/test-group" ); + remoteRepository.setRemoteIndexUrl( "http://localhost:" + port + "/repository/test-group/.indexer" ); + remoteRepository.setUserName( RedbackRoleConstants.ADMINISTRATOR_ACCOUNT_NAME ); + remoteRepository.setPassword( FakeCreateAdminService.ADMIN_TEST_PWD ); + + getRemoteRepositoriesService().addRemoteRepository( remoteRepository ); + + ProxyConnectorService proxyConnectorService = getProxyConnectorService(); + ProxyConnector proxyConnector = new ProxyConnector(); + proxyConnector.setProxyId( "foo-bar" ); + proxyConnector.setSourceRepoId( id ); + proxyConnector.setTargetRepoId( "all-merged" ); + proxyConnectorService.addProxyConnector( proxyConnector ); + + repositoriesService.scheduleDownloadRemoteIndex( "all-merged", true, true ); + + // wait a bit + timeout = 20000; + while ( timeout > 0 ) + { + Thread.sleep( 500 ); + timeout -= 500; + } + + SearchService searchService = getSearchService(); + + SearchRequest request = new SearchRequest(); + request.setRepositories( Arrays.asList( id ) ); + request.setGroupId( "org.apache.felix" ); + + List artifacts = searchService.searchArtifacts( request ); + assertFalse( artifacts.isEmpty() ); + assertEquals( 1, artifacts.size() ); + } +} diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/junit-4.9.jar b/archiva-modules/archiva-web/archiva-web-common/src/test/junit-4.9.jar new file mode 100644 index 000000000..142081561 Binary files /dev/null and b/archiva-modules/archiva-web/archiva-web-common/src/test/junit-4.9.jar differ diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0-patch1.jar b/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0-patch1.jar new file mode 100644 index 000000000..9c16c3ced Binary files /dev/null and b/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0-patch1.jar differ diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0-sources.jar b/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0-sources.jar new file mode 100644 index 000000000..9c16c3ced Binary files /dev/null and b/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0-sources.jar differ diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar b/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar new file mode 100644 index 000000000..9c16c3ced Binary files /dev/null and b/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar differ diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.pom b/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.pom new file mode 100644 index 000000000..b0d983fde --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.pom @@ -0,0 +1,28 @@ + + 4.0.0 + org.apache.archiva + archiva-search + jar + 1.0 + Archiva Search + http://archiva.apache.org + + + junit + junit + 3.8.1 + test + + + commons-lang + commons-lang + 2.3 + + + log4j + log4j + 1.2.8 + + + diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar b/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar new file mode 100644 index 000000000..843ee45bc Binary files /dev/null and b/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar differ diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom b/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom new file mode 100644 index 000000000..0b037a3a5 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom @@ -0,0 +1,23 @@ + + 4.0.0 + org.apache.archiva + archiva-test + jar + 1.0 + archiva-test + http://maven.apache.org + + + junit + junit + 3.8.1 + test + + + commons-lang + commons-lang + 2.3 + + + diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.jar b/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.jar new file mode 100644 index 000000000..e904a17c4 Binary files /dev/null and b/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.jar differ diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.pom b/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.pom new file mode 100644 index 000000000..04fdb4859 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.pom @@ -0,0 +1,28 @@ + + 4.0.0 + org.apache.archiva + archiva-test + jar + 2.0 + Archiva Test + http://archiva.apache.org + + + junit + junit + 3.8.1 + test + + + commons-lang + commons-lang + 2.3 + + + commons-io + commons-io + 1.4 + + + diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-webapp/1.0/archiva-webapp-1.0.pom b/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-webapp/1.0/archiva-webapp-1.0.pom new file mode 100644 index 000000000..ca28dc132 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-webapp/1.0/archiva-webapp-1.0.pom @@ -0,0 +1,23 @@ + + 4.0.0 + org.apache.archiva + archiva-webapp + war + 1.0 + Archiva Webapp + http://archiva.apache.org + + + junit + junit + 3.8.1 + test + + + log4j + log4j + 1.2.8 + + + diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-webapp/1.0/archiva-webapp-1.0.war b/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/archiva-webapp/1.0/archiva-webapp-1.0.war new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/test-webapp/1.0-SNAPSHOT/test-webapp-1.0-SNAPSHOT.war b/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/test-webapp/1.0-SNAPSHOT/test-webapp-1.0-SNAPSHOT.war new file mode 100644 index 000000000..5559103fd Binary files /dev/null and b/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/archiva/test-webapp/1.0-SNAPSHOT/test-webapp-1.0-SNAPSHOT.war differ diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.jar b/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.jar new file mode 100644 index 000000000..218330e3f Binary files /dev/null and b/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.jar differ diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.pom b/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.pom new file mode 100644 index 000000000..19831eefa --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/repositories/test-repo/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.pom @@ -0,0 +1,138 @@ + + + + org.apache.felix + felix-parent + 2.1 + ../pom/pom.xml + + 4.0.0 + bundle + Apache Felix Bundle Repository + Bundle repository service. + org.apache.felix.bundlerepository + 1.6.6 + + scm:svn:http://svn.apache.org/repos/asf/felix/releases/org.apache.felix.bundlerepository-1.6.6 + scm:svn:https://svn.apache.org/repos/asf/felix/releases/org.apache.felix.bundlerepository-1.6.6 + http://svn.apache.org/repos/asf/felix/releases/org.apache.felix.bundlerepository-1.6.6 + + + + ${project.groupId} + org.apache.felix.utils + 1.1.0 + true + + + ${project.groupId} + org.osgi.service.obr + 1.0.2 + true + + + ${project.groupId} + org.apache.felix.shell + 1.4.1 + true + + + net.sf.kxml + kxml2 + 2.3.0 + true + + + xmlpull + xmlpull + + + + + org.osgi + org.osgi.compendium + 4.0.0 + true + + + org.osgi + org.osgi.core + 4.1.0 + + + org.codehaus.woodstox + woodstox-core-asl + 4.0.7 + true + + + org.easymock + easymock + 2.4 + + + + + + org.apache.felix + maven-bundle-plugin + 2.3.4 + true + + + org.apache.felix.bundlerepository;version="2.0" + + org.kxml2.io, + org.xmlpull.v1, + org.apache.felix.bundlerepository.impl.*, + org.apache.felix.utils.* + + !javax.xml.parsers,!org.xml.sax,org.osgi.service.log;resolution:=optional,org.osgi.service.obr;resolution:=optional,javax.xml.stream;resolution:=optional,* + org.apache.felix.shell + ${project.artifactId}.impl.Activator + http://felix.apache.org/site/apache-felix-osgi-bundle-repository.html + http://felix.apache.org/site/downloads.cgi + http://felix.apache.org/site/downloads.cgi + ${project.artifactId} + The Apache Software Foundation + org.apache.felix.bundlerepository.RepositoryAdmin,org.osgi.service.obr.RepositoryAdmin + <_versionpolicy>[$(version;==;$(@)),$(version;+;$(@))) + META-INF/LICENSE=LICENSE,META-INF/LICENSE.kxml2=LICENSE.kxml2,META-INF/NOTICE=NOTICE,META-INF/DEPENDENCIES=DEPENDENCIES + + + + + org.apache.rat + apache-rat-plugin + + false + true + true + + doc/* + maven-eclipse.xml + .checkstyle + .externalToolBuilders/* + + + + + + diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/repository.xml b/archiva-modules/archiva-web/archiva-web-common/src/test/repository.xml new file mode 100644 index 000000000..0be86ebbd --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/repository.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/META-INF/spring-context.xml b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/META-INF/spring-context.xml new file mode 100644 index 000000000..4478e93dc --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/META-INF/spring-context.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + scheduler1 + org.quartz.simpl.SimpleThreadPool + 2 + 4 + org.quartz.simpl.RAMJobStore + + + + + + + + + + + + + + + + + + + ]]> + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-artifacts-download.xml b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-artifacts-download.xml new file mode 100644 index 000000000..2ade48455 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-artifacts-download.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + ]]> + + + + + + diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-merge-index-download.xml b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-merge-index-download.xml new file mode 100644 index 000000000..16b37542d --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-merge-index-download.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + ]]> + + + + + + + diff --git a/archiva-modules/archiva-web/archiva-webapp-js/pom.xml b/archiva-modules/archiva-web/archiva-webapp-js/pom.xml index 23d091491..84ed45085 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/pom.xml +++ b/archiva-modules/archiva-web/archiva-webapp-js/pom.xml @@ -797,24 +797,6 @@ - - org.eclipse.jetty - jetty-server - test - - - org.eclipse.jetty - jetty-plus - test - - - - org.apache.archiva - archiva-web-common - tests - test - ${project.version} - diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/test/java/org/apache/archiva/AbstractDownloadTest.java b/archiva-modules/archiva-web/archiva-webapp-js/src/test/java/org/apache/archiva/AbstractDownloadTest.java deleted file mode 100644 index fdf51e81b..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/test/java/org/apache/archiva/AbstractDownloadTest.java +++ /dev/null @@ -1,278 +0,0 @@ -package org.apache.archiva; -/* - * 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. - */ - -import junit.framework.TestCase; -import org.apache.archiva.rest.api.services.ManagedRepositoriesService; -import org.apache.archiva.rest.api.services.ProxyConnectorService; -import org.apache.archiva.rest.api.services.RemoteRepositoriesService; -import org.apache.archiva.rest.api.services.RepositoriesService; -import org.apache.archiva.rest.api.services.RepositoryGroupService; -import org.apache.archiva.rest.api.services.SearchService; -import org.apache.archiva.webdav.RepositoryServlet; -import org.apache.commons.lang.StringUtils; -import org.apache.cxf.common.util.Base64Utility; -import org.apache.cxf.jaxrs.client.JAXRSClientFactory; -import org.apache.cxf.jaxrs.client.WebClient; -import org.apache.cxf.transport.servlet.CXFServlet; -import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider; -import org.apache.archiva.redback.integration.security.role.RedbackRoleConstants; -import org.apache.archiva.redback.rest.api.model.User; -import org.apache.archiva.redback.rest.api.services.RoleManagementService; -import org.apache.archiva.redback.rest.api.services.UserService; -import org.apache.archiva.redback.rest.services.FakeCreateAdminService; -import org.eclipse.jetty.server.Connector; -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.session.SessionHandler; -import org.eclipse.jetty.servlet.ServletContextHandler; -import org.eclipse.jetty.servlet.ServletHolder; -import org.junit.After; -import org.junit.Before; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.web.context.ContextLoaderListener; - -import java.util.Collections; -import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner; -import org.junit.runner.RunWith; - -/** - * @author Olivier Lamy - */ -@RunWith( ArchivaBlockJUnit4ClassRunner.class ) -public abstract class AbstractDownloadTest - extends TestCase -{ - - protected Logger log = LoggerFactory.getLogger( getClass() ); - - static String previousAppServerBase; - - public String authorizationHeader = getAdminAuthzHeader(); - - public Server server = null; - - public int port; - - public static String encode( String uid, String password ) - { - return "Basic " + Base64Utility.encode( ( uid + ":" + password ).getBytes() ); - } - - public static String getAdminAuthzHeader() - { - String adminPwdSysProps = System.getProperty( "rest.admin.pwd" ); - if ( StringUtils.isBlank( adminPwdSysProps ) ) - { - return encode( RedbackRoleConstants.ADMINISTRATOR_ACCOUNT_NAME, FakeCreateAdminService.ADMIN_TEST_PWD ); - } - return encode( RedbackRoleConstants.ADMINISTRATOR_ACCOUNT_NAME, adminPwdSysProps ); - } - - - protected abstract String getSpringConfigLocation(); - - - protected String getRestServicesPath() - { - return "restServices"; - } - - - @Before - public void startServer() - throws Exception - { - - System.setProperty( "redback.admin.creation.file", "target/auto-admin-creation.properties" ); - this.server = new Server( 0 ); - - ServletContextHandler context = new ServletContextHandler(); - - context.setContextPath( "/" ); - - context.setInitParameter( "contextConfigLocation", getSpringConfigLocation() ); - - ContextLoaderListener contextLoaderListener = new ContextLoaderListener(); - - context.addEventListener( contextLoaderListener ); - - ServletHolder sh = new ServletHolder( CXFServlet.class ); - - SessionHandler sessionHandler = new SessionHandler(); - - context.setSessionHandler( sessionHandler ); - - context.addServlet( sh, "/" + getRestServicesPath() + "/*" ); - - ServletHolder repoSh = new ServletHolder( RepositoryServlet.class ); - context.addServlet( repoSh, "/repository/*" ); - - server.setHandler( context ); - this.server.start(); - Connector connector = this.server.getConnectors()[0]; - this.port = connector.getLocalPort(); - log.info( "start server on port " + this.port ); - - User user = new User(); - user.setEmail( "toto@toto.fr" ); - user.setFullName( "the root user" ); - user.setUsername( RedbackRoleConstants.ADMINISTRATOR_ACCOUNT_NAME ); - user.setPassword( FakeCreateAdminService.ADMIN_TEST_PWD ); - - getUserService( null ).createAdminUser( user ); - - - } - - - @After - public void tearDown() - throws Exception - { - System.clearProperty( "redback.admin.creation.file" ); - super.tearDown(); - if ( this.server != null ) - { - this.server.stop(); - } - } - - - protected ProxyConnectorService getProxyConnectorService() - { - ProxyConnectorService service = - JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", - ProxyConnectorService.class, - Collections.singletonList( new JacksonJaxbJsonProvider() ) ); - - WebClient.client( service ).header( "Authorization", authorizationHeader ); - WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000L ); - return service; - } - - protected RemoteRepositoriesService getRemoteRepositoriesService() - { - RemoteRepositoriesService service = - JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", - RemoteRepositoriesService.class, - Collections.singletonList( new JacksonJaxbJsonProvider() ) ); - - WebClient.client( service ).header( "Authorization", authorizationHeader ); - WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000L ); - return service; - } - - protected ManagedRepositoriesService getManagedRepositoriesService() - { - ManagedRepositoriesService service = - JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", - ManagedRepositoriesService.class, - Collections.singletonList( new JacksonJaxbJsonProvider() ) ); - - WebClient.client( service ).header( "Authorization", authorizationHeader ); - WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000L ); - return service; - } - - - protected RepositoryGroupService getRepositoryGroupService() - { - RepositoryGroupService service = - JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", - RepositoryGroupService.class, - Collections.singletonList( new JacksonJaxbJsonProvider() ) ); - - WebClient.client( service ).header( "Authorization", authorizationHeader ); - WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000L ); - return service; - } - - protected RepositoriesService getRepositoriesService() - { - RepositoriesService service = - JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", - RepositoriesService.class, - Collections.singletonList( new JacksonJaxbJsonProvider() ) ); - - WebClient.client( service ).header( "Authorization", authorizationHeader ); - WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000L ); - return service; - } - - protected SearchService getSearchService() - { - SearchService service = - JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", - SearchService.class, - Collections.singletonList( new JacksonJaxbJsonProvider() ) ); - - WebClient.client( service ).header( "Authorization", authorizationHeader ); - WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000L ); - return service; - } - - protected String getBaseUrl() - { - String baseUrlSysProps = System.getProperty( "archiva.baseRestUrl" ); - return StringUtils.isBlank( baseUrlSysProps ) ? "http://localhost:" + port : baseUrlSysProps; - } - - - protected RoleManagementService getRoleManagementService( String authzHeader ) - { - RoleManagementService service = - JAXRSClientFactory.create( "http://localhost:" + port + "/" + getRestServicesPath() + "/redbackServices/", - RoleManagementService.class, - Collections.singletonList( new JacksonJaxbJsonProvider() ) ); - - // for debuging purpose - WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 3000000L ); - - if ( authzHeader != null ) - { - WebClient.client( service ).header( "Authorization", authzHeader ); - } - return service; - } - - protected UserService getUserService( String authzHeader ) - { - UserService service = - JAXRSClientFactory.create( "http://localhost:" + port + "/" + getRestServicesPath() + "/redbackServices/", - UserService.class, Collections.singletonList( new JacksonJaxbJsonProvider() ) ); - - // for debuging purpose - WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 3000000L ); - - if ( authzHeader != null ) - { - WebClient.client( service ).header( "Authorization", authzHeader ); - } - return service; - } - - protected FakeCreateAdminService getFakeCreateAdminService() - { - return JAXRSClientFactory.create( - "http://localhost:" + port + "/" + getRestServicesPath() + "/fakeCreateAdminService/", - FakeCreateAdminService.class ); - } - -} diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/test/java/org/apache/archiva/DownloadArtifactsTest.java b/archiva-modules/archiva-web/archiva-webapp-js/src/test/java/org/apache/archiva/DownloadArtifactsTest.java deleted file mode 100644 index ff1c7322e..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/test/java/org/apache/archiva/DownloadArtifactsTest.java +++ /dev/null @@ -1,240 +0,0 @@ -package org.apache.archiva; -/* - * 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. - */ - -import org.apache.archiva.admin.model.beans.RemoteRepository; -import org.apache.archiva.redback.rest.api.services.RoleManagementService; -import org.apache.archiva.security.common.ArchivaRoleConstants; -import org.apache.commons.compress.utils.IOUtils; -import org.apache.commons.io.FileUtils; -import org.apache.maven.wagon.providers.http.HttpWagon; -import org.apache.maven.wagon.repository.Repository; -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.servlet.ServletContextHandler; -import org.eclipse.jetty.servlet.ServletHolder; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Enumeration; -import java.util.List; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; -import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner; - -/** - * @author Olivier Lamy - */ -@RunWith( ArchivaBlockJUnit4ClassRunner.class ) -public class DownloadArtifactsTest - extends AbstractDownloadTest -{ - - protected Logger log = LoggerFactory.getLogger( DownloadArtifactsTest.class ); - - public Server redirectServer = null; - - public int redirectPort; - - public Server repoServer = null; - - public int repoServerPort; - - @BeforeClass - public static void setAppServerBase() - { - previousAppServerBase = System.getProperty( "appserver.base" ); - System.setProperty( "appserver.base", "target/" + DownloadArtifactsTest.class.getName() ); - } - - - @AfterClass - public static void resetAppServerBase() - { - System.setProperty( "appserver.base", previousAppServerBase ); - } - - protected String getSpringConfigLocation() - { - return "classpath*:META-INF/spring-context.xml classpath*:spring-context-artifacts-download.xml"; - } - - @Before - public void startServer() - throws Exception - { - super.startServer(); - - // repo handler - - this.repoServer = new Server( 0 ); - - ServletHolder shRepo = new ServletHolder( RepoServlet.class ); - ServletContextHandler contextRepo = new ServletContextHandler(); - - contextRepo.setContextPath( "/" ); - contextRepo.addServlet( shRepo, "/*" ); - - repoServer.setHandler( contextRepo ); - repoServer.start(); - this.repoServerPort = repoServer.getConnectors()[0].getLocalPort(); - - //redirect handler - - this.redirectServer = new Server( 0 ); - ServletHolder shRedirect = new ServletHolder( RedirectServlet.class ); - ServletContextHandler contextRedirect = new ServletContextHandler(); - contextRedirect.setAttribute( "redirectToPort", Integer.toString( this.repoServerPort ) ); - - contextRedirect.setContextPath( "/" ); - contextRedirect.addServlet( shRedirect, "/*" ); - - redirectServer.setHandler( contextRedirect ); - redirectServer.start(); - this.redirectPort = redirectServer.getConnectors()[0].getLocalPort(); - log.info( "redirect server port {}", redirectPort ); - - - - } - - @After - public void tearDown() - throws Exception - { - super.tearDown(); - if ( this.redirectServer != null ) - { - this.redirectServer.stop(); - } - } - - @Test - public void downloadWithRemoteRedirect() - throws Exception - { - RemoteRepository remoteRepository = getRemoteRepositoriesService().getRemoteRepository( "central" ); - remoteRepository.setUrl( "http://localhost:" + redirectPort ); - getRemoteRepositoriesService().updateRemoteRepository( remoteRepository ); - - RoleManagementService roleManagementService = getRoleManagementService( authorizationHeader ); - - if ( !roleManagementService.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, - "internal" ) ) - { - roleManagementService.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, "internal" ); - } - - getUserService( authorizationHeader ).createGuestUser(); - roleManagementService.assignRole( ArchivaRoleConstants.TEMPLATE_GUEST, "guest" ); - - roleManagementService.assignTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, "internal", - "guest" ); - - getUserService( authorizationHeader ).removeFromCache( "guest" ); - - File file = new File( "target/junit-4.9.jar" ); - if ( file.exists() ) - { - file.delete(); - } - - HttpWagon httpWagon = new HttpWagon(); - httpWagon.connect( new Repository( "foo", "http://localhost:" + port ) ); - - httpWagon.get( "/repository/internal/junit/junit/4.9/junit-4.9.jar", file ); - - ZipFile zipFile = new ZipFile( file ); - List entries = getZipEntriesNames( zipFile ); - ZipEntry zipEntry = zipFile.getEntry( "org/junit/runners/JUnit4.class" ); - assertNotNull( "cannot find zipEntry org/junit/runners/JUnit4.class, entries: " + entries + ", content is: " - + FileUtils.readFileToString( file ), zipEntry ); - zipFile.close(); - file.deleteOnExit(); - } - - private List getZipEntriesNames( ZipFile zipFile ) - { - try - { - List entriesNames = new ArrayList(); - Enumeration entries = zipFile.entries(); - while ( entries.hasMoreElements() ) - { - entriesNames.add( entries.nextElement().getName() ); - } - return entriesNames; - } - catch ( Throwable e ) - { - log.info( "fail to get zipEntries " + e.getMessage(), e ); - } - return Collections.emptyList(); - } - - - public static class RedirectServlet - extends HttpServlet - { - @Override - protected void doGet( HttpServletRequest req, HttpServletResponse resp ) - throws ServletException, IOException - { - - LoggerFactory.getLogger( getClass() ).info( "redirect servlet receive: {}", req.getRequestURI() ); - resp.setStatus( 302 ); - resp.getWriter().write( "\n" + "\n" - + "302 Found\n" + "\n" + "

Found

\n" - + "

The document has moved here.

\n" - + "\n" + "\n" - + "\n" ); - resp.sendRedirect( "http://localhost:" + getServletContext().getAttribute( "redirectToPort" ) + "/maven2/" - + req.getRequestURI() ); - } - } - - public static class RepoServlet - extends HttpServlet - { - @Override - protected void doGet( HttpServletRequest req, HttpServletResponse resp ) - throws ServletException, IOException - { - File jar = new File( System.getProperty( "basedir" ), "src/test/junit-4.9.jar" ); - IOUtils.copy( new FileInputStream( jar ), resp.getOutputStream() ); - - } - } - - -} diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/test/java/org/apache/archiva/DownloadMergedIndexTest.java b/archiva-modules/archiva-web/archiva-webapp-js/src/test/java/org/apache/archiva/DownloadMergedIndexTest.java deleted file mode 100644 index 118ff0dc8..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/test/java/org/apache/archiva/DownloadMergedIndexTest.java +++ /dev/null @@ -1,183 +0,0 @@ -package org.apache.archiva; -/* - * 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. - */ - -import org.apache.archiva.admin.model.beans.ManagedRepository; -import org.apache.archiva.admin.model.beans.ProxyConnector; -import org.apache.archiva.admin.model.beans.RemoteRepository; -import org.apache.archiva.admin.model.beans.RepositoryGroup; -import org.apache.archiva.maven2.model.Artifact; -import org.apache.archiva.rest.api.model.SearchRequest; -import org.apache.archiva.rest.api.services.ManagedRepositoriesService; -import org.apache.archiva.rest.api.services.ProxyConnectorService; -import org.apache.archiva.rest.api.services.RepositoriesService; -import org.apache.archiva.rest.api.services.RepositoryGroupService; -import org.apache.archiva.rest.api.services.SearchService; -import org.apache.commons.io.FileUtils; -import org.apache.archiva.redback.integration.security.role.RedbackRoleConstants; -import org.apache.archiva.redback.rest.services.FakeCreateAdminService; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.io.File; -import java.util.Arrays; -import java.util.List; -import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner; - -/** - * @author Olivier Lamy - */ -@RunWith( ArchivaBlockJUnit4ClassRunner.class ) -public class DownloadMergedIndexTest - extends AbstractDownloadTest -{ - - @BeforeClass - public static void setAppServerBase() - { - previousAppServerBase = System.getProperty( "appserver.base" ); - System.setProperty( "appserver.base", "target/" + DownloadMergedIndexTest.class.getName() ); - } - - @AfterClass - public static void resetAppServerBase() - { - System.setProperty( "appserver.base", previousAppServerBase ); - } - - protected String getSpringConfigLocation() - { - return "classpath*:META-INF/spring-context.xml classpath*:spring-context-merge-index-download.xml"; - } - - @After - public void cleanup() - throws Exception - { - super.tearDown(); - File tmpIndexDir = new File( System.getProperty( "java.io.tmpdir" ) + "/tmpIndex" ); - if ( tmpIndexDir.exists() ) - { - FileUtils.deleteDirectory( tmpIndexDir ); - } - } - - - @Test - public void downloadMergedIndex() - throws Exception - { - File tmpIndexDir = new File( System.getProperty( "java.io.tmpdir" ) + "/tmpIndex" ); - if ( tmpIndexDir.exists() ) - { - FileUtils.deleteDirectory( tmpIndexDir ); - } - String id = Long.toString( System.currentTimeMillis() ); - ManagedRepository managedRepository = new ManagedRepository(); - managedRepository.setId( id ); - managedRepository.setName( "name of " + id ); - managedRepository.setLocation( "src/test/repositories/test-repo" ); - managedRepository.setIndexDirectory( System.getProperty( "java.io.tmpdir" ) + "/tmpIndex/" + id ); - - ManagedRepositoriesService managedRepositoriesService = getManagedRepositoriesService(); - - if ( managedRepositoriesService.getManagedRepository( id ) != null ) - { - managedRepositoriesService.deleteManagedRepository( id, false ); - } - - getManagedRepositoriesService().addManagedRepository( managedRepository ); - - RepositoriesService repositoriesService = getRepositoriesService(); - - repositoriesService.scanRepositoryNow( id, true ); - - // wait a bit to ensure index is finished - int timeout = 20000; - while ( timeout > 0 && repositoriesService.alreadyScanning( id ) ) - { - Thread.sleep( 500 ); - timeout -= 500; - } - - RepositoryGroupService repositoryGroupService = getRepositoryGroupService(); - - RepositoryGroup repositoryGroup = new RepositoryGroup(); - repositoryGroup.setId( "test-group" ); - repositoryGroup.setRepositories( Arrays.asList( id ) ); - - repositoryGroupService.addRepositoryGroup( repositoryGroup ); - - // create a repo with a remote on the one with index - id = Long.toString( System.currentTimeMillis() ); - managedRepository = new ManagedRepository(); - managedRepository.setId( id ); - managedRepository.setName( "name of " + id ); - managedRepository.setLocation( "src/test/repositories/test-repo" ); - managedRepository.setIndexDirectory( System.getProperty( "java.io.tmpdir" ) + "/tmpIndex/" + id ); - - if ( managedRepositoriesService.getManagedRepository( id ) != null ) - { - managedRepositoriesService.deleteManagedRepository( id, false ); - } - - getManagedRepositoriesService().addManagedRepository( managedRepository ); - - RemoteRepository remoteRepository = new RemoteRepository(); - remoteRepository.setId( "all-merged" ); - remoteRepository.setName( "all-merged" ); - remoteRepository.setDownloadRemoteIndex( true ); - remoteRepository.setUrl( "http://localhost:" + port + "/repository/test-group" ); - remoteRepository.setRemoteIndexUrl( "http://localhost:" + port + "/repository/test-group/.indexer" ); - remoteRepository.setUserName( RedbackRoleConstants.ADMINISTRATOR_ACCOUNT_NAME ); - remoteRepository.setPassword( FakeCreateAdminService.ADMIN_TEST_PWD ); - - getRemoteRepositoriesService().addRemoteRepository( remoteRepository ); - - ProxyConnectorService proxyConnectorService = getProxyConnectorService(); - ProxyConnector proxyConnector = new ProxyConnector(); - proxyConnector.setProxyId( "foo-bar" ); - proxyConnector.setSourceRepoId( id ); - proxyConnector.setTargetRepoId( "all-merged" ); - proxyConnectorService.addProxyConnector( proxyConnector ); - - repositoriesService.scheduleDownloadRemoteIndex( "all-merged", true, true ); - - // wait a bit - timeout = 20000; - while ( timeout > 0 ) - { - Thread.sleep( 500 ); - timeout -= 500; - } - - SearchService searchService = getSearchService(); - - SearchRequest request = new SearchRequest(); - request.setRepositories( Arrays.asList( id ) ); - request.setGroupId( "org.apache.felix" ); - - List artifacts = searchService.searchArtifacts( request ); - assertFalse( artifacts.isEmpty() ); - assertEquals( 1, artifacts.size() ); - } -} diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0-patch1.jar b/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0-patch1.jar deleted file mode 100644 index 9c16c3ced..000000000 Binary files a/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0-patch1.jar and /dev/null differ diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0-sources.jar b/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0-sources.jar deleted file mode 100644 index 9c16c3ced..000000000 Binary files a/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0-sources.jar and /dev/null differ diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar b/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar deleted file mode 100644 index 9c16c3ced..000000000 Binary files a/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.jar and /dev/null differ diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.pom b/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.pom deleted file mode 100644 index b0d983fde..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-search/1.0/archiva-search-1.0.pom +++ /dev/null @@ -1,28 +0,0 @@ - - 4.0.0 - org.apache.archiva - archiva-search - jar - 1.0 - Archiva Search - http://archiva.apache.org - - - junit - junit - 3.8.1 - test - - - commons-lang - commons-lang - 2.3 - - - log4j - log4j - 1.2.8 - - - diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar b/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar deleted file mode 100644 index 843ee45bc..000000000 Binary files a/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.jar and /dev/null differ diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom b/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom deleted file mode 100644 index 0b037a3a5..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-test/1.0/archiva-test-1.0.pom +++ /dev/null @@ -1,23 +0,0 @@ - - 4.0.0 - org.apache.archiva - archiva-test - jar - 1.0 - archiva-test - http://maven.apache.org - - - junit - junit - 3.8.1 - test - - - commons-lang - commons-lang - 2.3 - - - diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.jar b/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.jar deleted file mode 100644 index e904a17c4..000000000 Binary files a/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.jar and /dev/null differ diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.pom b/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.pom deleted file mode 100644 index 04fdb4859..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-test/2.0/archiva-test-2.0.pom +++ /dev/null @@ -1,28 +0,0 @@ - - 4.0.0 - org.apache.archiva - archiva-test - jar - 2.0 - Archiva Test - http://archiva.apache.org - - - junit - junit - 3.8.1 - test - - - commons-lang - commons-lang - 2.3 - - - commons-io - commons-io - 1.4 - - - diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-webapp/1.0/archiva-webapp-1.0.pom b/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-webapp/1.0/archiva-webapp-1.0.pom deleted file mode 100644 index ca28dc132..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-webapp/1.0/archiva-webapp-1.0.pom +++ /dev/null @@ -1,23 +0,0 @@ - - 4.0.0 - org.apache.archiva - archiva-webapp - war - 1.0 - Archiva Webapp - http://archiva.apache.org - - - junit - junit - 3.8.1 - test - - - log4j - log4j - 1.2.8 - - - diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-webapp/1.0/archiva-webapp-1.0.war b/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/archiva-webapp/1.0/archiva-webapp-1.0.war deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/test-webapp/1.0-SNAPSHOT/test-webapp-1.0-SNAPSHOT.war b/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/test-webapp/1.0-SNAPSHOT/test-webapp-1.0-SNAPSHOT.war deleted file mode 100644 index 5559103fd..000000000 Binary files a/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/archiva/test-webapp/1.0-SNAPSHOT/test-webapp-1.0-SNAPSHOT.war and /dev/null differ diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.jar b/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.jar deleted file mode 100644 index 218330e3f..000000000 Binary files a/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.jar and /dev/null differ diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.pom b/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.pom deleted file mode 100644 index 19831eefa..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/test/repositories/test-repo/org/apache/felix/org.apache.felix.bundlerepository/1.6.6/org.apache.felix.bundlerepository-1.6.6.pom +++ /dev/null @@ -1,138 +0,0 @@ - - - - org.apache.felix - felix-parent - 2.1 - ../pom/pom.xml - - 4.0.0 - bundle - Apache Felix Bundle Repository - Bundle repository service. - org.apache.felix.bundlerepository - 1.6.6 - - scm:svn:http://svn.apache.org/repos/asf/felix/releases/org.apache.felix.bundlerepository-1.6.6 - scm:svn:https://svn.apache.org/repos/asf/felix/releases/org.apache.felix.bundlerepository-1.6.6 - http://svn.apache.org/repos/asf/felix/releases/org.apache.felix.bundlerepository-1.6.6 - - - - ${project.groupId} - org.apache.felix.utils - 1.1.0 - true - - - ${project.groupId} - org.osgi.service.obr - 1.0.2 - true - - - ${project.groupId} - org.apache.felix.shell - 1.4.1 - true - - - net.sf.kxml - kxml2 - 2.3.0 - true - - - xmlpull - xmlpull - - - - - org.osgi - org.osgi.compendium - 4.0.0 - true - - - org.osgi - org.osgi.core - 4.1.0 - - - org.codehaus.woodstox - woodstox-core-asl - 4.0.7 - true - - - org.easymock - easymock - 2.4 - - - - - - org.apache.felix - maven-bundle-plugin - 2.3.4 - true - - - org.apache.felix.bundlerepository;version="2.0" - - org.kxml2.io, - org.xmlpull.v1, - org.apache.felix.bundlerepository.impl.*, - org.apache.felix.utils.* - - !javax.xml.parsers,!org.xml.sax,org.osgi.service.log;resolution:=optional,org.osgi.service.obr;resolution:=optional,javax.xml.stream;resolution:=optional,* - org.apache.felix.shell - ${project.artifactId}.impl.Activator - http://felix.apache.org/site/apache-felix-osgi-bundle-repository.html - http://felix.apache.org/site/downloads.cgi - http://felix.apache.org/site/downloads.cgi - ${project.artifactId} - The Apache Software Foundation - org.apache.felix.bundlerepository.RepositoryAdmin,org.osgi.service.obr.RepositoryAdmin - <_versionpolicy>[$(version;==;$(@)),$(version;+;$(@))) - META-INF/LICENSE=LICENSE,META-INF/LICENSE.kxml2=LICENSE.kxml2,META-INF/NOTICE=NOTICE,META-INF/DEPENDENCIES=DEPENDENCIES - - - - - org.apache.rat - apache-rat-plugin - - false - true - true - - doc/* - maven-eclipse.xml - .checkstyle - .externalToolBuilders/* - - - - - - diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/test/resources/spring-context-artifacts-download.xml b/archiva-modules/archiva-web/archiva-webapp-js/src/test/resources/spring-context-artifacts-download.xml deleted file mode 100644 index 2ade48455..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/test/resources/spring-context-artifacts-download.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - ]]> - - - - - - diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/test/resources/spring-context-merge-index-download.xml b/archiva-modules/archiva-web/archiva-webapp-js/src/test/resources/spring-context-merge-index-download.xml deleted file mode 100644 index 16b37542d..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/test/resources/spring-context-merge-index-download.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - ]]> - - - - - - - -- cgit v1.2.3