### Question:
MessageProcessorFactory { public static MessageProcessor createMessageProcessor(OMElement elem) { MessageProcessor processor = null; OMAttribute clssAtt = elem.getAttribute(CLASS_Q); if(clssAtt != null) { String clssName = clssAtt.getAttributeValue(); if (MessageProcessorConstants.DEPRECATED_FORWARDING_PROCESSOR_CLASS.equals(clssName)) { clssName = ScheduledMessageForwardingProcessor.class.getName(); } else if (MessageProcessorConstants.DEPRECATED_SAMPLING_PROCESSOR_CLASS.equals(clssName)) { clssName = SamplingProcessor.class.getName(); } try { Class cls = Class.forName(clssName); processor = (MessageProcessor) cls.newInstance(); } catch (Exception e) { handleException("Error while creating Message processor " + e.getMessage()); } } else { handleException("Can't create Message processor without a provider class"); } OMAttribute nameAtt = elem.getAttribute(NAME_Q); if (nameAtt != null) { assert processor != null; processor.setName(nameAtt.getAttributeValue()); } else { handleException("Can't create Message processor without a name "); } if (FORWARDING_PROCESSOR.equals(clssAtt.getAttributeValue())) { OMAttribute targetSequenceAtt = elem.getAttribute(TARGET_ENDPOINT_Q); if (targetSequenceAtt != null) { assert processor != null; processor.setTargetEndpoint(targetSequenceAtt.getAttributeValue()); } else { } } OMAttribute storeAtt = elem.getAttribute(MESSAGE_STORE_Q); if(storeAtt != null) { assert processor != null; processor.setMessageStoreName(storeAtt.getAttributeValue()); } else { handleException("Can't create a message processor with out a message Store"); } OMElement descriptionElem = elem.getFirstChildWithName(DESCRIPTION_Q); if (descriptionElem != null) { assert processor != null; processor.setDescription(descriptionElem.getText()); } assert processor != null; processor.setParameters(getParameters(elem)); return processor; }  static MessageProcessor createMessageProcessor(OMElement elem); static final String FORWARDING_PROCESSOR; static final QName CLASS_Q; static final QName TARGET_ENDPOINT_Q; static final QName SEQUENCE_Q; static final QName NAME_Q; static final QName PARAMETER_Q; static final QName MESSAGE_STORE_Q; }### Answer:
@Test public void testCreateMessageProcessor() throws XMLStreamException { String inputXML = "<messageProcessor\n" + " class=\"org.apache.synapse.message.processor.impl.forwarder." + "ScheduledMessageForwardingProcessor\"\n" + " messageStore=\"MyStore\" name=\"ScheduledProcessor\" targetEndpoint=\"StockQuoteServiceEp\" " + "xmlns=\"http: " <parameter name=\"interval\">10000</parameter>\n" + " <parameter name=\"throttle\">false</parameter>\n" + " <parameter name=\"target.endpoint\">StockQuoteServiceEp</parameter>\n" + " <description> test </description>" + " </messageProcessor>"; OMElement element = AXIOMUtil.stringToOM(inputXML); MessageProcessor messageProcessor = MessageProcessorFactory.createMessageProcessor(element); Assert.assertNotNull("MessageProcessor is not created", messageProcessor); }