@Override public void before() throws Exception { super.before(); String[] mpxs = new String[] { Iterators.get(allowU.iterator(), allowU.size() / 2) }; Mounts.Builder builder = Mounts.newBuilder(); int i = 0; for (String p : mpxs) { builder.mount("m" + i, p); i++; } mountInfoProvider = builder.build(); }
@Test public void mountsPlacedUnder() { MountInfoProvider mip = Mounts.newBuilder() .mount("first", "/b") .mount("second", "/d", "/b/a") .mount("third", "/h", "/b/c") .build(); Collection<Mount> mountsContainedBetweenPaths = mip.getMountsPlacedUnder("/b"); assertEquals(2, mountsContainedBetweenPaths.size()); } }
@Test public void testGetSupportedPathsWithDifferentMounts() { Set<String> expected = CUG_CONFIG.getConfigValue(PARAM_CUG_SUPPORTED_PATHS, ImmutableSet.<String>of()); MountInfoProvider mip = Mounts.newBuilder().mount("private", "/libs", "/apps", "/nonCugPath").build(); assertNotSame(expected, CugUtil.getSupportedPaths(CUG_CONFIG, mip)); assertEquals(expected, CugUtil.getSupportedPaths(CUG_CONFIG, mip)); }
@Test(expected = IllegalArgumentException.class) public void builderRejectsTooManyReadWriteStores_mixed() { MountInfoProvider mip = Mounts.newBuilder() .mount("temp", "/tmp") .readOnlyMount("readOnly", "/readOnly") .build(); new CompositeNodeStore.Builder(mip, new MemoryNodeStore()) .addMount("temp", new MemoryNodeStore()) .addMount("readOnly", new MemoryNodeStore()) .build(); }
@Test(expected = IllegalArgumentException.class) public void builderRejectsTooManyReadWriteStores_oneExtra() { MountInfoProvider mip = Mounts.newBuilder() .mount("temp", "/tmp") .build(); new CompositeNodeStore.Builder(mip, new MemoryNodeStore()) .addMount("temp", new MemoryNodeStore()) .build(); }
@Before public void initializeHook() { MountInfoProvider mip = Mounts.newBuilder() .mount("foo", "/a") .build(); hook = new EditorHook(new CompositeEditorProvider( new IndexUpdateProvider(new CompositeIndexEditorProvider( new PropertyIndexEditorProvider().with(mip), new ReferenceEditorProvider().with(mip))), new CrossMountReferenceValidatorProvider().with(mip).withFailOnDetection(true))); }
@Test(expected = IllegalStateException.class) public void testGetSupportedPathsMountsAboveSupportedPath2() { MountInfoProvider mip = Mounts.newBuilder().mount("private", PathUtils.getAncestorPath(SUPPORTED_PATH3, 2)).build(); CugUtil.getSupportedPaths(CUG_CONFIG, mip); }
@Test(expected = IllegalStateException.class) public void testGetSupportedPathsMountsBelowSupportedPath() { MountInfoProvider mip = Mounts.newBuilder().mount("private", "/libs", "/apps" ).build(); CugUtil.getSupportedPaths(ConfigurationParameters.of(PARAM_CUG_SUPPORTED_PATHS, new String[] {"/"}), mip); }
@Override @Before public void before() throws Exception { mountInfoProvider = Mounts.newBuilder().mount("testMount", testPath).build(); super.before(); }
@Test public void readOnlyMounting() throws Exception{ MountInfoProvider mip = Mounts.newBuilder() .mount("foo", "/a", "/b") .readOnlyMount("bar", "/x", "/y") .build(); assertTrue(mip.getMountByName("bar").isReadOnly()); assertFalse(mip.getMountByName("foo").isReadOnly()); }
@Test public void testMountBelowUnsupportedPath() { MountInfoProvider mip = Mounts.newBuilder().mount("mnt", AbstractCugTest.UNSUPPORTED_PATH + "/mount").build(); CugConfiguration configuration = createConfiguration(mip); assertArrayEquals(AbstractCugTest.SUPPORTED_PATHS, configuration.getParameters().getConfigValue(CugConstants.PARAM_CUG_SUPPORTED_PATHS, new String[0])); } }
@Test(expected = IllegalStateException.class) public void testMountBelowCugSupportedPath() { MountInfoProvider mip = Mounts.newBuilder().mount("mnt", AbstractCugTest.SUPPORTED_PATH + "/mount").build(); createConfiguration(mip); }
@Test(expected = IllegalStateException.class) public void testGetSupportedPathsMountsBelowSupportedPath2() { MountInfoProvider mip = Mounts.newBuilder().mount("private", "/libs", SUPPORTED_PATH + "/any/path/below").build(); CugUtil.getSupportedPaths(CUG_CONFIG, mip); }
@Test(expected = NullPointerException.class) public void mismatchBetweenMountNameAndStoreName() { MountInfoProvider mip = Mounts.newBuilder() .mount("temp", "/tmp") .build(); new CompositeNodeStore.Builder(mip, new MemoryNodeStore()) .addMount("not-temp", new MemoryNodeStore()) .build(); }
@Test(expected = IllegalArgumentException.class) public void mismatchBetweenMountsAndStoresIsRejected() { MountInfoProvider mip = Mounts.newBuilder() .mount("temp", "/tmp") .build(); new CompositeNodeStore.Builder(mip, new MemoryNodeStore()) .build(); }
@Test(expected = IllegalStateException.class) public void testMountAtCugSupportedPath() { MountInfoProvider mip = Mounts.newBuilder().mount("mnt", AbstractCugTest.SUPPORTED_PATH).build(); createConfiguration(mip); }
@Test(expected = IllegalStateException.class) public void testMountAtRootWithSupportedPaths() { MountInfoProvider mip = Mounts.newBuilder().mount("mnt", PathUtils.ROOT_PATH).build(); createConfiguration(mip); }
@Test(expected = IllegalStateException.class) public void testMountAboveCugSupportedPath() { MountInfoProvider mip = Mounts.newBuilder().mount("mnt", PathUtils.getParentPath(AbstractCugTest.SUPPORTED_PATH3)).build(); createConfiguration(mip); }
@Test(expected = IllegalStateException.class) public void testGetSupportedPathsMountsAboveSupportedPath() { MountInfoProvider mip = Mounts.newBuilder().mount("private", PathUtils.ROOT_PATH).build(); CugUtil.getSupportedPaths(CUG_CONFIG, mip); }
@Test public void basicMounting() throws Exception { MountInfoProvider mip = Mounts.newBuilder() .mount("foo", "/a", "/b") .mount("bar", "/x", "/y") .build(); assertEquals("foo", mip.getMountByPath("/a").getName()); assertEquals("foo", mip.getMountByPath("/a/x").getName()); assertEquals("bar", mip.getMountByPath("/x").getName()); assertTrue(mip.getMountByPath("/z").isDefault()); assertTrue(mip.hasNonDefaultMounts()); }