List of usage examples for org.apache.hadoop.fs ContentSummary getDirectoryCount
public long getDirectoryCount()
From source file:org.pentaho.hadoop.shim.common.DistributedCacheUtilImplOSDependentTest.java
License:Apache License
@Test public void stagePluginsForCache() throws Exception { DistributedCacheUtilImpl ch = new DistributedCacheUtilImpl(TEST_CONFIG); Configuration conf = new Configuration(); FileSystem fs = DistributedCacheTestUtil.getLocalFileSystem(conf); Path pluginsDir = new Path("bin/test/plugins-installation-dir"); FileObject pluginDir = DistributedCacheTestUtil.createTestFolderWithContent(); try {/*from w w w . jav a2 s. c o m*/ ch.stagePluginsForCache(fs, pluginsDir, "bin/test/sample-folder"); Path pluginInstallPath = new Path(pluginsDir, "bin/test/sample-folder"); assertTrue(fs.exists(pluginInstallPath)); ContentSummary summary = fs.getContentSummary(pluginInstallPath); assertEquals(6, summary.getFileCount()); assertEquals(6, summary.getDirectoryCount()); } finally { pluginDir.delete(new AllFileSelector()); fs.delete(pluginsDir, true); } }
From source file:org.slc.sli.aggregation.mapreduce.map.ValueMapperTest.java
License:Apache License
@SuppressWarnings({ "rawtypes", "unchecked" }) @Test//from ww w .j a v a2s . co m public void testMap() throws Exception { TenantAndIdEmittableKey key = new TenantAndIdEmittableKey(); ValueMapper m = new MockValueMapper(); BSONObject entry = new BasicBSONObject("found", "data"); BSONWritable entity = new BSONWritable(entry); Context context = Mockito.mock(Context.class); PowerMockito.when(context, "write", Matchers.any(EmittableKey.class), Matchers.any(BSONObject.class)) .thenAnswer(new Answer<BSONObject>() { @Override public BSONObject answer(InvocationOnMock invocation) throws Throwable { Object[] args = invocation.getArguments(); assertNotNull(args); assertEquals(args.length, 2); assertTrue(args[0] instanceof TenantAndIdEmittableKey); assertTrue(args[1] instanceof ContentSummary); TenantAndIdEmittableKey id = (TenantAndIdEmittableKey) args[0]; assertNotNull(id); ContentSummary e = (ContentSummary) args[1]; assertEquals(e.getLength(), 1); assertEquals(e.getFileCount(), 2); assertEquals(e.getDirectoryCount(), 3); return null; } }); m.map(key, entity, context); }