2 * Permission is hereby granted, free of charge, to any person obtaining a
3 * copy of this software and associated documentation files (the "Software"),
4 * to deal in the Software without restriction, including without limitation
5 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
6 * and/or sell copies of the Software, and to permit persons to whom the
7 * Software is furnished to do so, subject to the following conditions:
9 * The above copyright notice and this permission notice shall be included in
10 * all copies or substantial portions of the Software.
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18 * DEALINGS IN THE SOFTWARE.
22 import java.io.FileNotFoundException;
24 import java.util.UUID;
25 import static org.junit.Assert.*;
28 * This tests the mount root dir functionality. It creates an empty
29 * directory in the real root, then it re-mounts the file system
30 * with the empty directory specified as the root. Assertions are
31 * that the "/" in the normal mount is non-empty, and that "/" is
32 * empty in the mount with the empty directory as the root.
34 public class CephMountCreateTest {
36 private static String conf_file;
39 public static void class_setup() throws Exception {
40 conf_file = System.getProperty("CEPH_CONF_FILE");
43 private CephMount setupMount(String root) throws Exception {
44 CephMount mount = new CephMount("admin");
45 if (conf_file != null)
46 mount.conf_read_file(conf_file);
47 mount.conf_set("client_permissions", "0");
53 public void test_CephMountCreate() throws Exception {
57 String dir = "libcephfs_junit_" + UUID.randomUUID();
59 /* root dir has more than one dir */
60 mount = setupMount("/");
63 mount.rmdir("/" + dir);
64 } catch (FileNotFoundException e) {}
65 mount.mkdirs("/" + dir, 777);
66 String[] subdirs = mount.listdir("/");
68 for (String d : subdirs) {
69 if (d.compareTo(dir) == 0)
75 /* changing root to empty dir */
76 mount = setupMount("/" + dir);
78 subdirs = mount.listdir("/");
80 for (String d : subdirs) {
87 mount = setupMount("/");
88 mount.rmdir("/" + dir);