View Javadoc
1   package org.apache.maven.plugins.ejb;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  
23  import java.io.File;
24  
25  import org.junit.Assert;
26  import org.junit.Test;
27  
28  public class EjbHelperTest
29  {
30  
31      @Test
32      public void validClassifier()
33      {
34          Assert.assertTrue( EjbHelper.isClassifierValid( "anton" ) );
35      }
36  
37      @Test
38      public void anOtherValidClassifier()
39      {
40          Assert.assertTrue( EjbHelper.isClassifierValid( "jdk15" ) );
41      }
42  
43      @Test
44      public void moreValidClassifier()
45      {
46          Assert.assertTrue( EjbHelper.isClassifierValid( "client-classifier" ) );
47      }
48  
49      @Test
50      public void isClassifierValidShouldReturnFalseIfClassifierIsPrefixedByDash()
51      {
52          Assert.assertFalse( EjbHelper.isClassifierValid( "-anton" ) );
53      }
54  
55      @Test
56      public void isClassifierValidShouldReturnFalseIfClassifierIsNull()
57      {
58          Assert.assertFalse( EjbHelper.isClassifierValid( null ) );
59      }
60  
61      @Test
62      public void hasClassifierShouldReturnFalseForNull()
63      {
64          Assert.assertFalse( EjbHelper.hasClassifier( null ) );
65      }
66  
67      @Test
68      public void hasClassifierShouldReturnFalseForEmptyString()
69      {
70          Assert.assertFalse( EjbHelper.hasClassifier( "" ) );
71      }
72  
73      @Test
74      public void hasClassifierShouldReturnTrueForNonEmptyString()
75      {
76          Assert.assertTrue( EjbHelper.hasClassifier( "x" ) );
77      }
78  
79      @Test
80      public void getJarFileNameShouldReturnFileNameWithoutClassifier()
81      {
82          Assert.assertEquals( EjbHelper.getJarFile( new File( "base" ), "test", null ), new File( "base/test.jar" ) );
83      }
84  
85      @Test
86      public void getJarFileNameShouldReturnFileNameWithClassifier()
87      {
88          Assert.assertEquals( EjbHelper.getJarFile( new File( "base" ), "test",
89                                                "alpha" ), new File( "base/test-alpha.jar" ) );
90      }
91  }