View Javadoc
1   package org.apache.archiva.rest.services.utils;
2   /*
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
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
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
18   * under the License.
19   */
20  
21  import static org.assertj.core.api.Assertions.*;
22  
23  import java.io.File;
24  
25  import org.easymock.TestSubject;
26  import org.junit.Test;
27  
28  public class ArtifactBuilderTest
29  {
30      @TestSubject
31      private ArtifactBuilder builder = new ArtifactBuilder();
32  
33      @Test
34      public void testBuildSnapshot()
35      {
36          assertThat( builder.getExtensionFromFile( new File( "/tmp/foo-2.3-20141119.064321-40.jar" ) ) ).isEqualTo( "jar" );
37      }
38  
39      @Test
40      public void testBuildPom()
41      {
42          assertThat( builder.getExtensionFromFile( new File( "/tmp/foo-1.0.pom" ) ) ).isEqualTo( "pom" );
43      }
44  
45      @Test
46      public void testBuildJar()
47      {
48          assertThat( builder.getExtensionFromFile( new File( "/tmp/foo-1.0-sources.jar" ) ) ).isEqualTo( "jar" );
49      }
50  
51      @Test
52      public void testBuildTarGz()
53      {
54          assertThat( builder.getExtensionFromFile( new File( "/tmp/foo-1.0.tar.gz" ) ) ).isEqualTo( "tar.gz" );
55      }
56  
57      @Test
58      public void testBuildPomZip()
59      {
60          assertThat( builder.getExtensionFromFile( new File( "/tmp/foo-1.0.pom.zip" ) ) ).isEqualTo( "pom.zip" );
61      }
62  
63      @Test
64      public void testBuildR00()
65      {
66          assertThat( builder.getExtensionFromFile( new File( "/tmp/foo-1.0.r00" ) ) ).isEqualTo( "r00" );
67      }
68  }