### Question:
CGroupsHandlerImpl implements CGroupsHandler { @Override public void mountCGroupController(CGroupController controller) throws ResourceHandlerException { if (!enableCGroupMount) { LOG.warn("CGroup mounting is disabled - ignoring mount request for: " + controller.getName()); return; } String path = getControllerPath(controller); if (path == null) { try { rwLock.writeLock().lock(); String hierarchy = cGroupPrefix; StringBuffer controllerPath = new StringBuffer() .append(cGroupMountPath).append('/').append(controller.getName()); StringBuffer cGroupKV = new StringBuffer() .append(controller.getName()).append('=').append(controllerPath); PrivilegedOperation.OperationType opType = PrivilegedOperation .OperationType.MOUNT_CGROUPS; PrivilegedOperation op = new PrivilegedOperation(opType); op.appendArgs(hierarchy, cGroupKV.toString()); LOG.info("Mounting controller " + controller.getName() + " at " + controllerPath); privilegedOperationExecutor.executePrivilegedOperation(op, false); controllerPaths.put(controller, controllerPath.toString()); return; } catch (PrivilegedOperationException e) { LOG.error("Failed to mount controller: " + controller.getName()); throw new ResourceHandlerException("Failed to mount controller: " + controller.getName()); } finally { rwLock.writeLock().unlock(); } } else { LOG.info("CGroup controller already mounted at: " + path); return; } } CGroupsHandlerImpl(Configuration conf, PrivilegedOperationExecutor
      privilegedOperationExecutor); @Override void mountCGroupController(CGroupController controller); @Override String getRelativePathForCGroup(String cGroupId); @Override String getPathForCGroup(CGroupController controller, String cGroupId); @Override String getPathForCGroupTasks(CGroupController controller,
      String cGroupId); @Override String getPathForCGroupParam(CGroupController controller,
      String cGroupId, String param); @Override String createCGroup(CGroupController controller, String cGroupId); @Override void deleteCGroup(CGroupController controller, String cGroupId); @Override void updateCGroupParam(CGroupController controller, String cGroupId,
      String param, String value); @Override String getCGroupParam(CGroupController controller, String cGroupId,
      String param);  }### Answer:
@Test public void testMountController() { CGroupsHandler cGroupsHandler = null; verifyZeroInteractions(privilegedOperationExecutorMock); try { cGroupsHandler = new CGroupsHandlerImpl(conf, privilegedOperationExecutorMock); PrivilegedOperation expectedOp = new PrivilegedOperation (PrivilegedOperation.OperationType.MOUNT_CGROUPS); StringBuffer controllerKV = new StringBuffer(controller.getName()) .append('=').append(tmpPath).append('/').append(controller.getName()); expectedOp.appendArgs(hierarchy, controllerKV.toString()); cGroupsHandler.mountCGroupController(controller); try { ArgumentCaptor<PrivilegedOperation> opCaptor = ArgumentCaptor.forClass (PrivilegedOperation.class); verify(privilegedOperationExecutorMock) .executePrivilegedOperation(opCaptor.capture(), eq(false)); Assert.assertEquals(expectedOp, opCaptor.getValue()); verifyNoMoreInteractions(privilegedOperationExecutorMock); cGroupsHandler.mountCGroupController(controller); verifyNoMoreInteractions(privilegedOperationExecutorMock); } catch (PrivilegedOperationException e) { LOG.error("Caught exception: " + e); Assert.assertTrue("Unexpected PrivilegedOperationException from mock!", false); } } catch (ResourceHandlerException e) { LOG.error("Caught exception: " + e); Assert.assertTrue("Unexpected ResourceHandler Exception!", false); } }