0

I am implementing MUnit for a flow where I need to send the payload through a Set Message Processor as a CopyOnWriteArrayList. The payload data would be fetched from a file.

The file would have comma separated XML Data. I need this data to be sent as CopyOnWriteArrayList.

Please help me on the Java class that can be used in MEL.

Please find below updated details :

For the MUnit test, I have the data in a file as of the format [First_XML_Data,Second_XML_Data]. The First_XML_Data and Second_XML_Data are both XML data. So basically first component in mule flow is Java transformer as below:

public class XMLData extends AbstractTransformer {

@Override
protected Object doTransform(Object src, String enc) throws TransformerException {

        CopyOnWriteArrayList<String> list = (CopyOnWriteArrayList<String>) src;

}

}

As you can see, I need to prepare a payload in Set Message Processor so that it can be passed on to this Java transformer. So as of now I have the following MEL in set message processor of MUnit test,

[Arrays.asList((getResource('src/main/resources/xml_data.xml').asString().split(',')))]

The applications throws a type cast exception. So i need to some how send the payload as CopyOnWriteArrayList. As the data is too large , I am picking it up from the File

Thanks.

Community
  • 1
  • 1
  • What part of the problem are you having issues with? – Stephen C Jun 23 '16 at 11:40
  • What is comma separated XML data? It sounds like a contradiction in terms. – Stephen C Jun 23 '16 at 11:44
  • The payload that has to be sent for processing should be a CopyOnWriteArrayList type. The data is too large. Hence I am picking it up from a file through a MUnit matcher in MEL. So is there any way I can handle/convert the data in file (present as comma separated xml data) to CopyOnWriteArrayList – Shivchetan Sambaragimath Jun 23 '16 at 13:04
  • 1) What I am asking is **what part** of the problem is giving you problems? In other words, what have you tried. 2) Please reply to my second comment too. – Stephen C Jun 23 '16 at 13:43
  • Can you add some sample data and your current code of munit and flow? – Manik Magar Jun 23 '16 at 15:42
  • Stephen and Manik... Please find the data updated in the question. This would help you understand the scenario. – Shivchetan Sambaragimath Jun 27 '16 at 07:42

1 Answers1

0

Instead of use Arrays.asList(), you should construct the CopyOnWriteArrayList.

#[new java.util.concurrent.CopyOnWriteArrayList(getResource('src/main/resources/xml_data.xml').asString().split(','))]
sulthony h
  • 1,279
  • 1
  • 8
  • 9