1 package org.apache.archiva.rest.services;
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
22 import org.apache.archiva.admin.model.beans.ManagedRepository;
23 import org.apache.archiva.rest.api.services.ArchivaAdministrationService;
24 import org.apache.archiva.rest.api.services.ManagedRepositoriesService;
25 import org.apache.archiva.rest.api.services.NetworkProxyService;
26 import org.apache.archiva.rest.api.services.PingService;
27 import org.apache.archiva.rest.api.services.ProxyConnectorService;
28 import org.apache.archiva.rest.api.services.RemoteRepositoriesService;
29 import org.apache.archiva.rest.api.services.RepositoriesService;
30 import org.apache.archiva.rest.api.services.RepositoryGroupService;
31 import org.apache.archiva.rest.api.services.SearchService;
32 import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
33 import org.apache.cxf.jaxrs.client.WebClient;
34 import org.apache.archiva.common.utils.FileUtil;
35 import org.codehaus.redback.rest.services.AbstractRestServicesTest;
40 * @author Olivier Lamy
42 public abstract class AbstractArchivaRestTest
43 extends AbstractRestServicesTest
46 // START SNIPPET: authz-header
47 public String guestAuthzHeader =
48 "Basic " + org.apache.cxf.common.util.Base64Utility.encode( ( "guest" + ":" ).getBytes() );
49 // END SNIPPET: authz-header
52 protected String getSpringConfigLocation()
54 return "classpath*:META-INF/spring-context.xml,classpath:META-INF/spring-context-test.xml";
57 protected String getRestServicesPath()
59 return "restServices";
62 protected RepositoriesService getRepositoriesService()
64 return getRepositoriesService( null );
68 protected RepositoriesService getRepositoriesService( String authzHeader )
70 RepositoriesService service =
71 JAXRSClientFactory.create( "http://localhost:" + port + "/" + getRestServicesPath() + "/archivaServices/",
72 RepositoriesService.class );
74 if ( authzHeader != null )
76 WebClient.client( service ).header( "Authorization", authzHeader );
78 WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 );
83 protected ManagedRepositoriesService getManagedRepositoriesService( String authzHeader )
85 ManagedRepositoriesService service =
86 JAXRSClientFactory.create( "http://localhost:" + port + "/" + getRestServicesPath() + "/archivaServices/",
87 ManagedRepositoriesService.class );
89 if ( authzHeader != null )
91 WebClient.client( service ).header( "Authorization", authzHeader );
93 WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 );
98 protected PingService getPingService()
100 return JAXRSClientFactory.create(
101 "http://localhost:" + port + "/" + getRestServicesPath() + "/archivaServices/", PingService.class );
104 protected RemoteRepositoriesService getRemoteRepositoriesService()
106 return JAXRSClientFactory.create(
107 "http://localhost:" + port + "/" + getRestServicesPath() + "/archivaServices/",
108 RemoteRepositoriesService.class );
113 protected RepositoryGroupService getRepositoryGroupService()
115 return JAXRSClientFactory.create(
116 "http://localhost:" + port + "/" + getRestServicesPath() + "/archivaServices/",
117 RepositoryGroupService.class );
120 protected ProxyConnectorService getProxyConnectorService()
122 ProxyConnectorService service =
123 JAXRSClientFactory.create( "http://localhost:" + port + "/" + getRestServicesPath() + "/archivaServices/",
124 ProxyConnectorService.class );
126 WebClient.client( service ).header( "Authorization", authorizationHeader );
127 WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 );
131 protected NetworkProxyService getNetworkProxyService()
133 NetworkProxyService service =
134 JAXRSClientFactory.create( "http://localhost:" + port + "/" + getRestServicesPath() + "/archivaServices/",
135 NetworkProxyService.class );
137 WebClient.client( service ).header( "Authorization", authorizationHeader );
138 WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 );
142 protected ArchivaAdministrationService getArchivaAdministrationService()
144 ArchivaAdministrationService service =
145 JAXRSClientFactory.create( "http://localhost:" + port + "/" + getRestServicesPath() + "/archivaServices/",
146 ArchivaAdministrationService.class );
148 WebClient.client( service ).header( "Authorization", authorizationHeader );
149 WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 );
153 protected SearchService getSearchService( String authzHeader )
155 // START SNIPPET: cxf-searchservice-creation
156 SearchService service =
157 JAXRSClientFactory.create( "http://localhost:" + port + "/" + getRestServicesPath() + "/archivaServices/",
158 SearchService.class );
160 if ( authzHeader != null )
162 WebClient.client( service ).header( "Authorization", authzHeader );
164 WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 );
166 // END SNIPPET: cxf-searchservice-creation
170 protected ManagedRepository getTestManagedRepository()
172 String location = new File( FileUtil.getBasedir(), "target/test-repo" ).getAbsolutePath();
173 return new ManagedRepository( "TEST", "test", location, "default", true, true, false, "2 * * * * ?", null,
174 false, 2, 3, true, false );