]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1714] using LDAP can be configurable with the ui
authorOlivier Lamy <olamy@apache.org>
Fri, 23 Nov 2012 13:31:13 +0000 (13:31 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 23 Nov 2012 13:31:13 +0000 (13:31 +0000)
add unit test for rest services

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1412883 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaRuntimeConfigurationServiceTest.java [new file with mode: 0644]

index b3ab173e9dc6ef76943aea32213011b2f756ce38..7faae9e230db905810c0ef80c4dc7cd8d71e0cf7 100644 (file)
@@ -58,11 +58,13 @@ public class DefaultArchivaRuntimeConfigurationService
         try
         {
             archivaRuntimeConfigurationAdmin.updateArchivaRuntimeConfiguration( archivaRuntimeConfiguration );
+            return Boolean.TRUE;
         }
         catch ( RepositoryAdminException e )
         {
             throw new ArchivaRestServiceException( e.getMessage(), e );
         }
+
     }
 }
 
index ee6ff9156a2cd188d21bbf243a766e1a5ccf50c9..523279de76417284c421f6f01af55a9a740afa64 100644 (file)
@@ -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 (file)
index 0000000..88225bf
--- /dev/null
@@ -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() );
+
+
+    }
+
+
+}