1 package org.apache.archiva.admin.repository.admin;
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.repository.AbstractRepositoryAdminTest;
22 import org.apache.archiva.admin.repository.RepositoryAdminException;
23 import org.junit.Test;
25 import javax.inject.Inject;
26 import java.util.Arrays;
29 * @author Olivier Lamy
31 public class ArchivaAdministrationTest
32 extends AbstractRepositoryAdminTest
35 ArchivaAdministration archivaAdministration;
39 public void getAllLegacyPaths()
42 assertNotNull( archivaAdministration.getLegacyArtifactPaths() );
43 assertFalse( archivaAdministration.getLegacyArtifactPaths().isEmpty() );
44 assertEquals( 1, archivaAdministration.getLegacyArtifactPaths().size() );
45 log.info( "all legacy paths {}", archivaAdministration.getLegacyArtifactPaths() );
48 public void addAndDeleteLegacyPath()
51 int initialSize = archivaAdministration.getLegacyArtifactPaths().size();
53 LegacyArtifactPath legacyArtifactPath = new LegacyArtifactPath( "foo", "bar" );
54 archivaAdministration.addLegacyArtifactPath( legacyArtifactPath, getFakeAuditInformation() );
56 assertTrue( archivaAdministration.getLegacyArtifactPaths().contains( new LegacyArtifactPath( "foo", "bar" ) ) );
57 assertEquals( initialSize + 1, archivaAdministration.getLegacyArtifactPaths().size() );
59 archivaAdministration.deleteLegacyArtifactPath( legacyArtifactPath.getPath(), getFakeAuditInformation() );
62 archivaAdministration.getLegacyArtifactPaths().contains( new LegacyArtifactPath( "foo", "bar" ) ) );
63 assertEquals( initialSize, archivaAdministration.getLegacyArtifactPaths().size() );
67 public void addAndUpdateAndDeleteFileType()
68 throws RepositoryAdminException
70 int initialSize = archivaAdministration.getRepositoryScanning().getFileTypes().size();
72 FileType fileType = new FileType();
73 fileType.setId( "foo" );
74 fileType.setPatterns( Arrays.asList( "bar", "toto" ) );
76 archivaAdministration.addFileType( fileType, getFakeAuditInformation() );
78 assertEquals( initialSize + 1, archivaAdministration.getRepositoryScanning().getFileTypes().size() );
80 archivaAdministration.addFileTypePattern( "foo", "zorro", getFakeAuditInformation() );
82 assertEquals( initialSize + 1, archivaAdministration.getRepositoryScanning().getFileTypes().size() );
84 assertEquals( 3, archivaAdministration.getFileType( "foo" ).getPatterns().size() );
86 assertTrue( archivaAdministration.getFileType( "foo" ).getPatterns().contains( "bar" ) );
87 assertTrue( archivaAdministration.getFileType( "foo" ).getPatterns().contains( "toto" ) );
88 assertTrue( archivaAdministration.getFileType( "foo" ).getPatterns().contains( "zorro" ) );
90 archivaAdministration.removeFileTypePattern( "foo", "zorro", getFakeAuditInformation() );
92 assertEquals( initialSize + 1, archivaAdministration.getRepositoryScanning().getFileTypes().size() );
94 assertEquals( 2, archivaAdministration.getFileType( "foo" ).getPatterns().size() );
96 assertTrue( archivaAdministration.getFileType( "foo" ).getPatterns().contains( "bar" ) );
97 assertTrue( archivaAdministration.getFileType( "foo" ).getPatterns().contains( "toto" ) );
98 assertFalse( archivaAdministration.getFileType( "foo" ).getPatterns().contains( "zorro" ) );
100 archivaAdministration.removeFileType( "foo", getFakeAuditInformation() );
102 assertEquals( initialSize, archivaAdministration.getRepositoryScanning().getFileTypes().size() );
103 assertNull( archivaAdministration.getFileType( "foo" ) );