### Question:
CommonUtil { public static boolean addHandler(Registry configSystemRegistry, String payload) throws RegistryException, XMLStreamException { String name; OMElement element = AXIOMUtil.stringToOM(payload); if (element != null) { name = element.getAttributeValue(new QName("class")); } else return false; if (isHandlerNameInUse(name)) throw new RegistryException("The added handler name is already in use!"); String path = getContextRoot() + name; Resource resource; if (!handlerExists(configSystemRegistry, name)) { resource = new ResourceImpl(); } else { throw new RegistryException("The added handler name is already in use!"); } resource.setContent(payload); try { configSystemRegistry.beginTransaction(); configSystemRegistry.put(path, resource); generateHandler(configSystemRegistry, path); configSystemRegistry.commitTransaction(); } catch (Exception e) { configSystemRegistry.rollbackTransaction(); throw new RegistryException("Unable to generate handler", e); } return true; }  static synchronized void setRegistryService(RegistryService service); static RegistryService getRegistryService(); static void simulateRegistryOperation(Registry rootRegistry, SimulationRequest simulationRequest); static SimulationResponse getSimulationResponse(); static boolean updateHandler(Registry configSystemRegistry, String oldName, String payload); static boolean addHandler(Registry configSystemRegistry, String payload); static boolean handlerExists(Registry configSystemRegistry, String name); static boolean deleteHandler(Registry configSystemRegistry, String name); static String getHandlerConfiguration(Registry configSystemRegistry, String name); static String[] getHandlerList(Registry configSystemRegistry); static String getContextRoot(); static void setContextRoot(String contextRoot); static boolean generateHandler(Registry configSystemRegistry, String resourceFullPath); static boolean removeHandler(Registry configSystemRegistry, String handlerName); static boolean isHandlerNameInUse(String name); static boolean addDefaultHandlersIfNotAvailable(Registry configSystemRegistry); static SimulationService getSimulationService(); static void setSimulationService(SimulationService simulationService); static HandlerConfigurationBean deserializeHandlerConfiguration(OMElement configurationElement); static OMElement serializeHandlerConfiguration(HandlerConfigurationBean bean);  }### Answer:
@Test public void testAddHandler() throws Exception { String handlerName = "org.wso2.carbon.registry.extensions.handlers.ServiceMediaTypeHandler"; assertTrue(CommonUtil.addHandler(registry, handlerConfiguration)); String[] handlerList = CommonUtil.getHandlerList(registry); assertArrayEquals(new String[]{handlerName}, handlerList); String handlerConfig = CommonUtil.getHandlerConfiguration(registry, handlerName); assertEquals(handlerConfiguration, handlerConfig); assertTrue(CommonUtil.updateHandler(registry, handlerName, updateHandlerConfig)); String updatedHandlerName = "org.wso2.carbon.registry.extensions.handlers.DeleteSubscriptionHandler"; handlerList = CommonUtil.getHandlerList(registry); assertArrayEquals(new String[]{updatedHandlerName}, handlerList); String updatedHandlerConfig = CommonUtil.getHandlerConfiguration(registry, updatedHandlerName); assertEquals(updateHandlerConfig, updatedHandlerConfig); assertTrue(CommonUtil.deleteHandler(registry, updatedHandlerName)); handlerList = CommonUtil.getHandlerList(registry); assertArrayEquals(null, handlerList); }