View Javadoc

1   /*
2    * Copyright 2013 Codehaus.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.codehaus.mojo.nbm;
17  
18  import java.io.File;
19  import org.junit.Test;
20  import static org.junit.Assert.*;
21  
22  /**
23   *
24   * @author mkleint
25   */
26  public class BrandingMojoTest
27  {
28      
29      public BrandingMojoTest()
30      {
31      }
32  
33      /**
34       * Test of destinationFileName method, of class BrandingMojo.
35       */
36      @Test
37      public void testDestinationFileName()
38      {
39          assertEquals( "cut_brandingToken.gif", BrandingMojo.destinationFileName( "cut.gif", "brandingToken" ) );
40          assertEquals( "cut_brandingToken", BrandingMojo.destinationFileName( "cut", "brandingToken" ) );
41          assertEquals( "cut_pressed_brandingToken.gif", BrandingMojo.destinationFileName( "cut_pressed.gif", "brandingToken" ) );
42          assertEquals( "path1" + File.separator + "path2" + File.separator + "cut_brandingToken", BrandingMojo.destinationFileName( "path1" + File.separator + "path2" + File.separator + "cut", "brandingToken" ) );
43          assertEquals( "path.1" + File.separator + "path.2" + File.separator + "cut_brandingToken", BrandingMojo.destinationFileName( "path.1" + File.separator + "path.2" + File.separator + "cut", "brandingToken" ) );
44          assertEquals( "path.1" + File.separator + "cut_pressed_brandingToken.gif", BrandingMojo.destinationFileName( "path.1" + File.separator + "cut_pressed.gif", "brandingToken" ) );
45      }
46      
47      @Test
48      public void testLocale() {
49          assertEquals("en_us", BrandingMojo.getLocale( "aaa_en_us.properties")[1]);
50          assertEquals("en_us_ca", BrandingMojo.getLocale( "aaa_en_us_ca.properties")[1]);
51          assertEquals("en_us_ca", BrandingMojo.getLocale( "aa_en_us_ca.properties")[1]);
52          assertEquals("en_us_ca", BrandingMojo.getLocale( "bb_aa_en_us_ca.properties")[1]);
53          assertEquals("en", BrandingMojo.getLocale( "bb_aaa_en.properties")[1]);
54          assertEquals(null, BrandingMojo.getLocale( "bb_aaa_end.properties")[1]);
55          assertEquals(null, BrandingMojo.getLocale( "bb_aa_end.properties")[1]);
56          assertEquals(null, BrandingMojo.getLocale( "bb.properties")[1]);
57      }
58  }