From 8fd2aba5e71b4fd6d7a64d9d456dd661c60332e9 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Fri, 23 Nov 2012 13:31:13 +0000 Subject: [PATCH] [MRM-1714] using LDAP can be configurable with the ui add unit test for rest services git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1412883 13f79535-47bb-0310-9956-ffa450edef68 --- ...ultArchivaRuntimeConfigurationService.java | 2 + .../services/AbstractArchivaRestTest.java | 15 +++++ ...rchivaRuntimeConfigurationServiceTest.java | 58 +++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaRuntimeConfigurationServiceTest.java diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java index b3ab173e9..7faae9e23 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java @@ -58,11 +58,13 @@ public class DefaultArchivaRuntimeConfigurationService try { archivaRuntimeConfigurationAdmin.updateArchivaRuntimeConfiguration( archivaRuntimeConfiguration ); + return Boolean.TRUE; } catch ( RepositoryAdminException e ) { throw new ArchivaRestServiceException( e.getMessage(), e ); } + } } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java index ee6ff9156..523279de7 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java @@ -23,6 +23,7 @@ import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.common.utils.FileUtil; import org.apache.archiva.redback.rest.services.AbstractRestServicesTest; import org.apache.archiva.rest.api.services.ArchivaAdministrationService; +import org.apache.archiva.rest.api.services.ArchivaRuntimeConfigurationService; import org.apache.archiva.rest.api.services.BrowseService; import org.apache.archiva.rest.api.services.CommonServices; import org.apache.archiva.rest.api.services.ManagedRepositoriesService; @@ -222,6 +223,20 @@ public abstract class AbstractArchivaRestTest return service; } + protected ArchivaRuntimeConfigurationService getArchivaRuntimeConfigurationService() + { + ArchivaRuntimeConfigurationService service = JAXRSClientFactory.create( + getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", + ArchivaRuntimeConfigurationService.class, Collections.singletonList( new JacksonJaxbJsonProvider() ) ); + + WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE ); + WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE ); + + WebClient.client( service ).header( "Authorization", authorizationHeader ); + WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 ); + return service; + } + protected BrowseService getBrowseService( String authzHeader, boolean useXml ) { BrowseService service = diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaRuntimeConfigurationServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaRuntimeConfigurationServiceTest.java new file mode 100644 index 000000000..88225bf93 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaRuntimeConfigurationServiceTest.java @@ -0,0 +1,58 @@ +package org.apache.archiva.rest.services; +/* + * 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.ArchivaRuntimeConfiguration; +import org.junit.Test; + +/** + * @author Olivier Lamy + */ +public class ArchivaRuntimeConfigurationServiceTest + extends AbstractArchivaRestTest +{ + @Test + public void nonnullConfiguration() + throws Exception + { + ArchivaRuntimeConfiguration archivaRuntimeConfiguration = + getArchivaRuntimeConfigurationService().getArchivaRuntimeConfigurationAdmin(); + assertEquals( "jdo", archivaRuntimeConfiguration.getUserManagerImpl() ); + } + + @Test + public void update() + throws Exception + { + ArchivaRuntimeConfiguration archivaRuntimeConfiguration = + getArchivaRuntimeConfigurationService().getArchivaRuntimeConfigurationAdmin(); + assertEquals( "jdo", archivaRuntimeConfiguration.getUserManagerImpl() ); + + archivaRuntimeConfiguration.setUserManagerImpl( "foo" ); + + getArchivaRuntimeConfigurationService().updateArchivaRuntimeConfiguration( archivaRuntimeConfiguration ); + + archivaRuntimeConfiguration = getArchivaRuntimeConfigurationService().getArchivaRuntimeConfigurationAdmin(); + assertEquals( "foo", archivaRuntimeConfiguration.getUserManagerImpl() ); + + + } + + +} -- 2.39.5