### Question:
TaskManagerFactory { public static TaskManager createTaskManager(OMElement elem, Properties properties) { OMAttribute prov = elem.getAttribute(PROVIDER_Q); if (prov != null) { try { Class provider = Class.forName(prov.getAttributeValue()); TaskManager taskManager = (TaskManager) provider.newInstance(); taskManager.init(getProperties(elem, properties)); taskManager.setConfigurationProperties(getProperties(elem, properties)); return taskManager; } catch (ClassNotFoundException e) { handleException("Cannot locate task provider class : " + prov.getAttributeValue(), e); } catch (IllegalAccessException e) { handleException("Error instantiating task provider : " + prov.getAttributeValue(), e); } catch (InstantiationException e) { handleException("Error instantiating task provider : " + prov.getAttributeValue(), e); } } else { handleException("The task 'provider' " + "attribute is required for a taskManager definition"); } return null; }  static TaskManager createTaskManager(OMElement elem, Properties properties); static final QName PROVIDER_Q; static final QName PARAMETER_Q; static final QName NAME_Q; }### Answer:
@Test public void testCreateTaskManager() throws XMLStreamException { String inputXML = "<taskManager provider=\"org.apache.synapse.startup.quartz.QuartzTaskManager\"/>"; OMElement element = AXIOMUtil.stringToOM(inputXML); TaskManager taskManager = TaskManagerFactory.createTaskManager(element, null); Assert.assertTrue("TaskManager is not created.", taskManager instanceof QuartzTaskManager); }
@Test public void testCreateTaskManager2() throws XMLStreamException { String inputXML = "<taskManager provider=\"org.apache.synapse.startup.quartz.QuartzTaskManager\">" + "<parameter xmlns=\"http: + "</taskManager>"; OMElement element = AXIOMUtil.stringToOM(inputXML); TaskManager taskManager = TaskManagerFactory.createTaskManager(element, null); Assert.assertTrue("TaskManager is not created.", taskManager instanceof QuartzTaskManager); }
@Test public void testCreateTaskManager3() throws XMLStreamException { expectedEx.expect(SynapseException.class); expectedEx.expectMessage("Cannot locate task provider class : " + "org.apache.synapse.startup.quartz.QuartzTaskManagerDummy"); String inputXML = "<taskManager provider=\"org.apache.synapse.startup.quartz.QuartzTaskManagerDummy\">" + "<parameter xmlns=\"http: + "</taskManager>"; OMElement element = AXIOMUtil.stringToOM(inputXML); TaskManagerFactory.createTaskManager(element, null); }
@Test public void testCreateTaskManager4() throws XMLStreamException { expectedEx.expect(SynapseException.class); expectedEx.expectMessage("The task 'provider' attribute is required for a taskManager definition"); String inputXML = "<taskManager>" + "<parameter xmlns=\"http: + "</taskManager>"; OMElement element = AXIOMUtil.stringToOM(inputXML); TaskManagerFactory.createTaskManager(element, null); }