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
21 import org.apache.archiva.admin.model.beans.FileType;
22 import org.apache.archiva.admin.model.beans.LegacyArtifactPath;
23 import org.apache.archiva.admin.model.beans.OrganisationInformation;
24 import org.apache.archiva.admin.model.beans.UiConfiguration;
25 import org.apache.commons.lang.StringUtils;
26 import org.junit.Test;
28 import java.util.Arrays;
31 * @author Olivier Lamy
33 public class ArchivaAdministrationServiceTest
34 extends AbstractArchivaRestTest
37 public void getAllLegacyPaths()
40 assertNotNull( getArchivaAdministrationService().getLegacyArtifactPaths() );
41 assertFalse( getArchivaAdministrationService().getLegacyArtifactPaths().isEmpty() );
45 public void addAndDeleteLegacyPath()
48 int initialSize = getArchivaAdministrationService().getLegacyArtifactPaths().size();
49 LegacyArtifactPath legacyArtifactPath = new LegacyArtifactPath();
50 legacyArtifactPath.setArtifact( "foo" );
51 legacyArtifactPath.setPath( "bar" );
52 getArchivaAdministrationService().addLegacyArtifactPath( legacyArtifactPath );
53 assertEquals( initialSize + 1, getArchivaAdministrationService().getLegacyArtifactPaths().size() );
55 getArchivaAdministrationService().deleteLegacyArtifactPath( "bar" );
56 assertEquals( initialSize, getArchivaAdministrationService().getLegacyArtifactPaths().size() );
60 public void addAndDeleteFileType()
63 int initialSize = getArchivaAdministrationService().getFileTypes().size();
64 FileType fileType = new FileType();
65 fileType.setId( "footwo" );
66 fileType.setPatterns( Arrays.asList( "foo", "bar" ) );
67 getArchivaAdministrationService().addFileType( fileType );
68 assertEquals( initialSize + 1, getArchivaAdministrationService().getFileTypes().size() );
70 assertNotNull( getArchivaAdministrationService().getFileType( "footwo" ) );
71 assertEquals( Arrays.asList( "foo", "bar" ),
72 getArchivaAdministrationService().getFileType( "footwo" ).getPatterns() );
74 getArchivaAdministrationService().removeFileType( "footwo" );
76 assertEquals( initialSize, getArchivaAdministrationService().getFileTypes().size() );
78 assertNull( getArchivaAdministrationService().getFileType( "footwo" ) );
82 public void organisationInformationUpdate()
85 OrganisationInformation organisationInformation =
86 getArchivaAdministrationService().getOrganisationInformation();
88 // rest return an empty bean
89 assertNotNull( organisationInformation );
90 assertTrue( StringUtils.isBlank( organisationInformation.getLogoLocation() ) );
91 assertTrue( StringUtils.isBlank( organisationInformation.getName() ) );
92 assertTrue( StringUtils.isBlank( organisationInformation.getUrl() ) );
94 organisationInformation = new OrganisationInformation();
95 organisationInformation.setLogoLocation( "http://foo.com/bar.png" );
96 organisationInformation.setName( "foo org" );
97 organisationInformation.setUrl( "http://foo.com" );
99 getArchivaAdministrationService().setOrganisationInformation( organisationInformation );
101 organisationInformation = getArchivaAdministrationService().getOrganisationInformation();
102 assertNotNull( organisationInformation );
103 assertEquals( "http://foo.com/bar.png", organisationInformation.getLogoLocation() );
104 assertEquals( "foo org", organisationInformation.getName() );
105 assertEquals( "http://foo.com", organisationInformation.getUrl() );
109 public void uiConfigurationReadUpdate()
112 UiConfiguration ui = getArchivaAdministrationService().getUiConfiguration();
114 // assert default values
115 assertFalse( ui.isDisableEasterEggs() );
116 assertTrue( ui.isAppletFindEnabled() );
117 assertTrue( ui.isShowFindArtifacts() );
119 ui.setAppletFindEnabled( false );
120 ui.setShowFindArtifacts( false );
121 ui.setDisableEasterEggs( true );
123 getArchivaAdministrationService().setUiConfiguration( ui );
125 ui = getArchivaAdministrationService().getUiConfiguration();
127 assertTrue( ui.isDisableEasterEggs() );
128 assertFalse( ui.isAppletFindEnabled() );
129 assertFalse( ui.isShowFindArtifacts() );