1 package org.apache.archiva.rest.services.utils;
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.common.filelock.DefaultFileLockManager;
22 import org.apache.archiva.repository.storage.fs.FilesystemAsset;
23 import org.apache.archiva.repository.storage.fs.FilesystemStorage;
24 import org.apache.archiva.repository.storage.StorageAsset;
25 import org.easymock.TestSubject;
26 import org.junit.Test;
28 import java.io.IOException;
29 import java.nio.file.Path;
30 import java.nio.file.Paths;
32 import static org.assertj.core.api.Assertions.assertThat;
34 public class ArtifactBuilderTest
37 private ArtifactBuilder builder = new ArtifactBuilder();
39 StorageAsset getFile(String path) throws IOException {
40 Path filePath = Paths.get(path);
41 FilesystemStorage filesystemStorage = new FilesystemStorage(filePath.getParent(), new DefaultFileLockManager());
42 return new FilesystemAsset(filesystemStorage, filePath.getFileName().toString(), filePath);
46 public void testBuildSnapshot() throws IOException {
47 assertThat( builder.getExtensionFromFile( getFile( "/tmp/foo-2.3-20141119.064321-40.jar" ) ) ).isEqualTo( "jar" );
51 public void testBuildPom() throws IOException {
52 assertThat( builder.getExtensionFromFile( getFile( "/tmp/foo-1.0.pom" ) ) ).isEqualTo( "pom" );
56 public void testBuildJar() throws IOException {
57 assertThat( builder.getExtensionFromFile( getFile( "/tmp/foo-1.0-sources.jar" ) ) ).isEqualTo( "jar" );
61 public void testBuildTarGz() throws IOException {
62 assertThat( builder.getExtensionFromFile( getFile( "/tmp/foo-1.0.tar.gz" ) ) ).isEqualTo( "tar.gz" );
66 public void testBuildPomZip() throws IOException {
67 assertThat( builder.getExtensionFromFile( getFile( "/tmp/foo-1.0.pom.zip" ) ) ).isEqualTo( "pom.zip" );
71 public void testBuildR00() throws IOException {
72 assertThat( builder.getExtensionFromFile( getFile( "/tmp/foo-1.0.r00" ) ) ).isEqualTo( "r00" );