Esempio n. 1
0
  @Test
  public void testC() throws IOException {

    //
    // Test the getBranch(..)
    //

    AbstractFileResource f0 = MountPoint.getRoot();

    AbstractFileResource f1 = new DirectoryResource(f0, "Name1", FILE);
    f1.attach();

    AbstractFileResource f2 = new DirectoryResource(f1, "Name2", FILE);
    f2.attach();

    AbstractFileResource f3 = new DirectoryResource(f2, "Name3", FILE);
    f3.attach();

    String[] t0 = MountPoint.split("/Test1/Test2/Test3");
    AbstractFileResource r0 = MountPoint.getBranch(t0);
    assertEquals(r0, f0);

    String[] t1 = MountPoint.split("/Name1/Test1/Test2");
    AbstractFileResource r1 = MountPoint.getBranch(t1);
    assertEquals(r1, f1);

    String[] t2 = MountPoint.split("/Name1/Name2/Test2");
    AbstractFileResource r2 = MountPoint.getBranch(t2);
    assertEquals(r2, f2);

    String[] t3 = MountPoint.split("/Name1/Name2/Name3");
    AbstractFileResource r3 = MountPoint.getBranch(t3);
    assertEquals(r3, f3);
  }
Esempio n. 2
0
  @Test
  public void testA() {

    //
    // Test the split function
    //

    assertArrayEquals(MountPoint.split(""), new String[] {});
    assertArrayEquals(MountPoint.split("/"), new String[] {});
    assertArrayEquals(MountPoint.split("/Name1"), new String[] {"Name1"});
    assertArrayEquals(MountPoint.split("/Name1/"), new String[] {"Name1"});
    assertArrayEquals(MountPoint.split("/Name1/Name2"), new String[] {"Name1", "Name2"});
    assertArrayEquals(MountPoint.split("/Name1/Name2/"), new String[] {"Name1", "Name2"});
    assertArrayEquals(
        MountPoint.split("/Name1/Name2/Name3"), new String[] {"Name1", "Name2", "Name3"});
    assertArrayEquals(
        MountPoint.split("/Name1/Name2/Name3/"), new String[] {"Name1", "Name2", "Name3"});
  }