TestUnixFakeFileSystem.groovy revision f11ac5bf4a82c9be1ccd4933dedf730df3276e01
1/*
2 * Copyright 2008 the original author or authors.
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 */
16package org.mockftpserver.fake.filesystem
17
18/**
19 * Test-only subclass of UnixFakeFileSystem. Groovy implementation enables access to metaclass.
20 *
21 * @version $Revision: 160 $ - $Date: 2008-11-15 08:46:23 -0500 (Sat, 15 Nov 2008) $
22 *
23 * @author Chris Mair
24 */
25class TestUnixFakeFileSystem extends UnixFakeFileSystem {
26
27    Throwable addMethodException
28    Throwable renameMethodException
29    Throwable listNamesMethodException
30    Throwable deleteMethodException
31
32    void add(FileSystemEntry entry) {
33        if (addMethodException) {
34            throw addMethodException
35        }
36        super.add(entry)
37    }
38
39    void rename(String fromPath, String toPath) {
40        if (renameMethodException) {
41            throw renameMethodException
42        }
43        super.rename(fromPath, toPath)
44    }
45
46    List listNames(String path) {
47        if (listNamesMethodException) {
48            throw listNamesMethodException
49        }
50        super.listNames(path)
51    }
52
53    boolean delete(String path) {
54        if (deleteMethodException) {
55            throw deleteMethodException
56        }
57        super.delete(path)
58    }
59
60}