@@ -0,0 +1,2019 @@
+package nl.nn.adapterframework.pipes;%0A%0Aimport org.junit.Test;%0Aimport org.junit.rules.ExpectedException;%0Aimport org.mockito.Mock;%0A%0Aimport nl.nn.adapterframework.configuration.ConfigurationException;%0Aimport nl.nn.adapterframework.core.IPipeLineSession;%0Aimport nl.nn.adapterframework.core.PipeRunException;%0A%0Aimport static org.junit.Assert.*;%0A%0Aimport org.json.JSONArray;%0Aimport org.json.JSONObject;%0Aimport org.json.JSONTokener;%0Aimport org.json.XML;%0Aimport org.junit.Rule;%0A%0Apublic class JsonPipeTest %7B%0A%09@Mock%0A%09private IPipeLineSession%3C?, ?%3E session;%0A%0A%09@Rule%0A%09public ExpectedException exception = ExpectedException.none();%0A%0A%09private JsonPipe jsonPipe = new JsonPipe();%0A%0A%09@Test%0A%09public void configureInputNull() throws ConfigurationException %7B%0A%09%09exception.expect(ConfigurationException.class);%0A%09%09jsonPipe.configure();%0A%09%7D%0A%0A%09@Test%0A%09public void configureInputWrong() throws ConfigurationException %7B%0A%09%09jsonPipe.setDirection(%22foutje!%22);%0A%09%09exception.expect(ConfigurationException.class);%0A%09%09jsonPipe.configure();%0A%09%7D%0A%0A%09@Test%0A%09public void doPipeInputNull() throws Exception %7B%0A%09%09exception.expect(PipeRunException.class);%0A%09%09jsonPipe.doPipe(null, session);%0A%09%7D%0A%0A%09@Test%0A%09public void doPipeInputWrongObject() throws Exception %7B%0A%09%09Integer input = new Integer(1);%0A%09%09exception.expect(PipeRunException.class);%0A%09%09jsonPipe.doPipe(input, session);%0A%09%7D%0A%0A%09@Test%0A%09public void doPipeInputObject() throws Exception %7B%0A%09%09String stringResult = %22%7B name: Lars %7D%22;%0A%09%09JSONTokener jsonTokener = new JSONTokener(stringResult);%0A%09%09JSONObject jsonObject = new JSONObject(jsonTokener);%0A%09%09stringResult = XML.toString(jsonObject);%0A%09%09assertEquals(stringResult, %22%3Cname%3ELars%3C/name%3E%22);%0A%09%7D%0A%0A%09@Test%0A%09public void doPipeInputArray() throws Exception %7B%0A%09%09String stringResult = %22%5B %5C%22Wie%5C%22, %5C%22dit leest%5C%22, %5C%22is gek%5C%22 %5D%22;%0A%09%09JSONTokener jsonTokener = new JSONTokener(stringResult);%0A%09%09JSONArray jsonArray = new JSONArray(jsonTokener);%0A%09%09stringResult = XML.toString(jsonArray);%0A%09%09assertEquals(stringResult,%0A%09%09%09%09%22%3Carray%3EWie%3C/array%3E%3Carray%3Edit leest%3C/array%3E%3Carray%3Eis gek%3C/array%3E%22);%0A%09%7D%0A%7D%0A

Add JUnit test for JsonPipe (by Lars)