1fba2635c088b01af59300e8a02611bb788ee3bffchrismair/* 2fba2635c088b01af59300e8a02611bb788ee3bffchrismair * Copyright 2008 the original author or authors. 3fba2635c088b01af59300e8a02611bb788ee3bffchrismair * 4fba2635c088b01af59300e8a02611bb788ee3bffchrismair * Licensed under the Apache License, Version 2.0 (the "License"); 5fba2635c088b01af59300e8a02611bb788ee3bffchrismair * you may not use this file except in compliance with the License. 6fba2635c088b01af59300e8a02611bb788ee3bffchrismair * You may obtain a copy of the License at 7fba2635c088b01af59300e8a02611bb788ee3bffchrismair * 8fba2635c088b01af59300e8a02611bb788ee3bffchrismair * http://www.apache.org/licenses/LICENSE-2.0 9fba2635c088b01af59300e8a02611bb788ee3bffchrismair * 10fba2635c088b01af59300e8a02611bb788ee3bffchrismair * Unless required by applicable law or agreed to in writing, software 11fba2635c088b01af59300e8a02611bb788ee3bffchrismair * distributed under the License is distributed on an "AS IS" BASIS, 12fba2635c088b01af59300e8a02611bb788ee3bffchrismair * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13fba2635c088b01af59300e8a02611bb788ee3bffchrismair * See the License for the specific language governing permissions and 14fba2635c088b01af59300e8a02611bb788ee3bffchrismair * limitations under the License. 15fba2635c088b01af59300e8a02611bb788ee3bffchrismair */ 16fba2635c088b01af59300e8a02611bb788ee3bffchrismairpackage org.mockftpserver.fake.filesystem 17fba2635c088b01af59300e8a02611bb788ee3bffchrismair 18fba2635c088b01af59300e8a02611bb788ee3bffchrismair/** 19fba2635c088b01af59300e8a02611bb788ee3bffchrismair * Test-only subclass of UnixFakeFileSystem. Groovy implementation enables access to metaclass. 20fba2635c088b01af59300e8a02611bb788ee3bffchrismair * 21fba2635c088b01af59300e8a02611bb788ee3bffchrismair * @version $Revision$ - $Date$ 22fba2635c088b01af59300e8a02611bb788ee3bffchrismair * 23fba2635c088b01af59300e8a02611bb788ee3bffchrismair * @author Chris Mair 24fba2635c088b01af59300e8a02611bb788ee3bffchrismair */ 25fba2635c088b01af59300e8a02611bb788ee3bffchrismairclass TestUnixFakeFileSystem extends UnixFakeFileSystem { 26fba2635c088b01af59300e8a02611bb788ee3bffchrismair 27fba2635c088b01af59300e8a02611bb788ee3bffchrismair Throwable addMethodException 28fba2635c088b01af59300e8a02611bb788ee3bffchrismair Throwable renameMethodException 29fba2635c088b01af59300e8a02611bb788ee3bffchrismair Throwable listNamesMethodException 30fba2635c088b01af59300e8a02611bb788ee3bffchrismair Throwable listFilesMethodException 31fba2635c088b01af59300e8a02611bb788ee3bffchrismair Throwable deleteMethodException 32fba2635c088b01af59300e8a02611bb788ee3bffchrismair 33fba2635c088b01af59300e8a02611bb788ee3bffchrismair void add(FileSystemEntry entry) { 34fba2635c088b01af59300e8a02611bb788ee3bffchrismair if (addMethodException) { 35fba2635c088b01af59300e8a02611bb788ee3bffchrismair throw addMethodException 36fba2635c088b01af59300e8a02611bb788ee3bffchrismair } 37fba2635c088b01af59300e8a02611bb788ee3bffchrismair super.add(entry) 38fba2635c088b01af59300e8a02611bb788ee3bffchrismair } 39fba2635c088b01af59300e8a02611bb788ee3bffchrismair 40fba2635c088b01af59300e8a02611bb788ee3bffchrismair void rename(String fromPath, String toPath) { 41fba2635c088b01af59300e8a02611bb788ee3bffchrismair if (renameMethodException) { 42fba2635c088b01af59300e8a02611bb788ee3bffchrismair throw renameMethodException 43fba2635c088b01af59300e8a02611bb788ee3bffchrismair } 44fba2635c088b01af59300e8a02611bb788ee3bffchrismair super.rename(fromPath, toPath) 45fba2635c088b01af59300e8a02611bb788ee3bffchrismair } 46fba2635c088b01af59300e8a02611bb788ee3bffchrismair 47fba2635c088b01af59300e8a02611bb788ee3bffchrismair List listNames(String path) { 48fba2635c088b01af59300e8a02611bb788ee3bffchrismair if (listNamesMethodException) { 49fba2635c088b01af59300e8a02611bb788ee3bffchrismair throw listNamesMethodException 50fba2635c088b01af59300e8a02611bb788ee3bffchrismair } 51fba2635c088b01af59300e8a02611bb788ee3bffchrismair super.listNames(path) 52fba2635c088b01af59300e8a02611bb788ee3bffchrismair } 53fba2635c088b01af59300e8a02611bb788ee3bffchrismair 54fba2635c088b01af59300e8a02611bb788ee3bffchrismair List listFiles(String path) { 55fba2635c088b01af59300e8a02611bb788ee3bffchrismair if (listFilesMethodException) { 56fba2635c088b01af59300e8a02611bb788ee3bffchrismair throw listFilesMethodException 57fba2635c088b01af59300e8a02611bb788ee3bffchrismair } 58fba2635c088b01af59300e8a02611bb788ee3bffchrismair super.listFiles(path) 59fba2635c088b01af59300e8a02611bb788ee3bffchrismair } 60fba2635c088b01af59300e8a02611bb788ee3bffchrismair 61fba2635c088b01af59300e8a02611bb788ee3bffchrismair boolean delete(String path) { 62fba2635c088b01af59300e8a02611bb788ee3bffchrismair if (deleteMethodException) { 63fba2635c088b01af59300e8a02611bb788ee3bffchrismair throw deleteMethodException 64fba2635c088b01af59300e8a02611bb788ee3bffchrismair } 65fba2635c088b01af59300e8a02611bb788ee3bffchrismair super.delete(path) 66fba2635c088b01af59300e8a02611bb788ee3bffchrismair } 67fba2635c088b01af59300e8a02611bb788ee3bffchrismair 68fba2635c088b01af59300e8a02611bb788ee3bffchrismair}