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 //Path jaxen/jars/jaxen-1.0-FCS-full.jar
49 //Artifact jaxen:jaxen:1.0-FCS:full:jar
50 int initialSize = getArchivaAdministrationService().getLegacyArtifactPaths().size();
51 LegacyArtifactPath legacyArtifactPath = new LegacyArtifactPath();
52 legacyArtifactPath.setArtifact( "wine:bordeaux:2006:GREAT:jar" );
53 legacyArtifactPath.setPath( "wine/jars/bordeaux-2006-GREAT.jar" );
54 getArchivaAdministrationService().addLegacyArtifactPath( legacyArtifactPath );
55 assertEquals( initialSize + 1, getArchivaAdministrationService().getLegacyArtifactPaths().size() );
57 getArchivaAdministrationService().deleteLegacyArtifactPath( "wine/jars/bordeaux-2006-GREAT.jar" );
58 assertEquals( initialSize, getArchivaAdministrationService().getLegacyArtifactPaths().size() );
62 public void addAndDeleteFileType()
65 int initialSize = getArchivaAdministrationService().getFileTypes().size();
66 FileType fileType = new FileType();
67 fileType.setId( "footwo" );
68 fileType.setPatterns( Arrays.asList( "foo", "bar" ) );
69 getArchivaAdministrationService().addFileType( fileType );
70 assertEquals( initialSize + 1, getArchivaAdministrationService().getFileTypes().size() );
72 assertNotNull( getArchivaAdministrationService().getFileType( "footwo" ) );
73 assertEquals( Arrays.asList( "foo", "bar" ),
74 getArchivaAdministrationService().getFileType( "footwo" ).getPatterns() );
76 getArchivaAdministrationService().removeFileType( "footwo" );
78 assertEquals( initialSize, getArchivaAdministrationService().getFileTypes().size() );
80 assertNull( getArchivaAdministrationService().getFileType( "footwo" ) );
84 public void organisationInformationUpdate()
87 OrganisationInformation organisationInformation =
88 getArchivaAdministrationService().getOrganisationInformation();
90 // rest return an empty bean
91 assertNotNull( organisationInformation );
92 assertTrue( StringUtils.isBlank( organisationInformation.getLogoLocation() ) );
93 assertTrue( StringUtils.isBlank( organisationInformation.getName() ) );
94 assertTrue( StringUtils.isBlank( organisationInformation.getUrl() ) );
96 organisationInformation = new OrganisationInformation();
97 organisationInformation.setLogoLocation( "http://foo.com/bar.png" );
98 organisationInformation.setName( "foo org" );
99 organisationInformation.setUrl( "http://foo.com" );
101 getArchivaAdministrationService().setOrganisationInformation( organisationInformation );
103 organisationInformation = getArchivaAdministrationService().getOrganisationInformation();
104 assertNotNull( organisationInformation );
105 assertEquals( "http://foo.com/bar.png", organisationInformation.getLogoLocation() );
106 assertEquals( "foo org", organisationInformation.getName() );
107 assertEquals( "http://foo.com", organisationInformation.getUrl() );
111 public void uiConfigurationReadUpdate()
114 UiConfiguration ui = getArchivaAdministrationService().getUiConfiguration();
116 // assert default values
117 assertFalse( ui.isDisableEasterEggs() );
118 assertTrue( ui.isAppletFindEnabled() );
119 assertTrue( ui.isShowFindArtifacts() );
121 ui.setAppletFindEnabled( false );
122 ui.setShowFindArtifacts( false );
123 ui.setDisableEasterEggs( true );
125 getArchivaAdministrationService().setUiConfiguration( ui );
127 ui = getArchivaAdministrationService().getUiConfiguration();
129 assertTrue( ui.isDisableEasterEggs() );
130 assertFalse( ui.isAppletFindEnabled() );
131 assertFalse( ui.isShowFindArtifacts() );