View Javadoc
1   package org.apache.maven.wagon;
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  import junit.framework.TestCase;
23  
24  /**
25   * Unit test for PermissionModeUtils class
26   *
27   * @author <a href="mailto:juam at users.sourceforge.net">Juan F. Codagnone</a>
28   * @see PermissionModeUtils
29   * @since Sep 3, 2005
30   */
31  public class PermissionModeUtilsTest
32      extends TestCase
33  {
34      /**
35       * @throws Exception on error
36       */
37      public void testNumeric()
38          throws Exception
39      {
40          final String[][] tests = {
41              {"0", "777"},
42              {"0000", "777"},
43              {"770", "7"},
44              {"0770", "7"},
45              {"0123", "654"},
46              {"9", null},
47              {"678", null},
48              {"ug+rwX,o-rwX", "ug+rwX,o-rwX"},
49              {"1770", "7"},
50              {"14770", "7"},
51  
52          };
53  
54          for ( String[] test : tests )
55          {
56              String umask = null;
57  
58              try
59              {
60                  umask = PermissionModeUtils.getUserMaskFor( test[ 0 ] );
61              }
62              catch ( IllegalArgumentException e )
63              {
64                  // nothing to do
65              }
66  
67              assertEquals( test[ 1 ], umask );
68          }
69      }
70  }