001package org.apache.maven.wagon; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import junit.framework.TestCase; 023 024/** 025 * Unit test for PermissionModeUtils class 026 * 027 * @author <a href="mailto:juam at users.sourceforge.net">Juan F. Codagnone</a> 028 * @see PermissionModeUtils 029 * @since Sep 3, 2005 030 */ 031public class PermissionModeUtilsTest 032 extends TestCase 033{ 034 /** 035 * @throws Exception on error 036 */ 037 public void testNumeric() 038 throws Exception 039 { 040 final String[][] tests = { 041 {"0", "777"}, 042 {"0000", "777"}, 043 {"770", "7"}, 044 {"0770", "7"}, 045 {"0123", "654"}, 046 {"9", null}, 047 {"678", null}, 048 {"ug+rwX,o-rwX", "ug+rwX,o-rwX"}, 049 {"1770", "7"}, 050 {"14770", "7"}, 051 052 }; 053 054 for ( String[] test : tests ) 055 { 056 String umask = null; 057 058 try 059 { 060 umask = PermissionModeUtils.getUserMaskFor( test[ 0 ] ); 061 } 062 catch ( IllegalArgumentException e ) 063 { 064 // nothing to do 065 } 066 067 assertEquals( test[ 1 ], umask ); 068 } 069 } 070}