commit 4bbe7b5a853c574b4adf95b8df59b82d62ddc54a
Author: Alexander Oppermann <a.oppermann@bgbm.org>
Date:   Mon Mar 31 08:25:42 2014 +0000

    Generate CSV file from pojo

diff --git a/.gitattributes b/.gitattributes
index 5d5d3c1989..d81f634f33 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2093,6 +2093,7 @@ cdmlib-remote/src/test/java/eu/etaxonomy/cdm/remote/dto/assembler/lsid/Assembler
 cdmlib-remote/src/test/java/eu/etaxonomy/cdm/remote/service/AuthorityControllerTest.java -text
 cdmlib-remote/src/test/java/eu/etaxonomy/cdm/remote/service/DataControllerTest.java -text
 cdmlib-remote/src/test/java/eu/etaxonomy/cdm/remote/service/MetadataControllerTest.java -text
+cdmlib-remote/src/test/java/eu/etaxonomy/cdm/remote/view/JsonToCsvViewTest.java -text
 cdmlib-remote/src/test/java/eu/etaxonomy/cdm/remote/view/OaiPmhViewTest.java -text
 cdmlib-remote/src/test/java/eu/etaxonomy/cdm/remote/view/RdfViewTest.java -text
 cdmlib-remote/src/test/java/eu/etaxonomy/cdm/test/function/GenericRemoteTester.java -text
diff --git a/cdmlib-remote/src/test/java/eu/etaxonomy/cdm/remote/view/JsonToCsvViewTest.java b/cdmlib-remote/src/test/java/eu/etaxonomy/cdm/remote/view/JsonToCsvViewTest.java
new file mode 100644
index 0000000000..02c18a1e07
--- /dev/null
+++ b/cdmlib-remote/src/test/java/eu/etaxonomy/cdm/remote/view/JsonToCsvViewTest.java
@@ -0,0 +1,107 @@
+package eu.etaxonomy.cdm.remote.view;
+
+import java.io.File;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.dozer.Mapper;
+import org.joda.time.DateTime;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.springframework.oxm.Marshaller;
+import org.unitils.UnitilsJUnit4;
+import org.unitils.spring.annotation.SpringApplicationContext;
+import org.unitils.spring.annotation.SpringBeanByName;
+import org.unitils.spring.annotation.SpringBeanByType;
+
+import eu.etaxonomy.cdm.io.csv.redlist.demo.CsvDemoExportConfigurator;
+import eu.etaxonomy.cdm.io.csv.redlist.demo.CsvDemoMetaDataRecord;
+import eu.etaxonomy.cdm.io.csv.redlist.demo.CsvDemoRecord;
+import eu.etaxonomy.cdm.model.common.LSID;
+import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.cdm.model.taxon.TaxonBase;
+import eu.etaxonomy.cdm.remote.view.oaipmh.IdentifyView;
+import eu.etaxonomy.cdm.remote.view.oaipmh.ListIdentifiersView;
+import eu.etaxonomy.cdm.remote.view.oaipmh.ListMetadataFormatsView;
+import eu.etaxonomy.cdm.remote.view.oaipmh.ListSetsView;
+import eu.etaxonomy.cdm.remote.view.oaipmh.dc.ListRecordsView;
+
+@Ignore
+@SpringApplicationContext("file:./target/test-classes/eu/etaxonomy/cdm/applicationContext-test.xml")
+public class JsonToCsvViewTest extends UnitilsJUnit4 {
+
+    public static final Logger logger = Logger.getLogger(JsonToCsvViewTest.class);
+
+    @SpringBeanByName
+    private Marshaller marshaller;
+
+    @SpringBeanByType
+    private Mapper mapper;
+
+    private Map<String,Object> model;
+    private IdentifyView identifyView;
+    private CsvDemoRecord demoRecord;
+    private MockHttpServletRequest request;
+    private MockHttpServletResponse response;
+
+    private URI serverURI;
+
+	private CsvDemoMetaDataRecord metaDataRecord;
+
+	private CsvDemoExportConfigurator config;
+
+    @Before
+    public void setUp() throws Exception {
+    
+        model = new HashMap<String,Object>();
+        identifyView = new IdentifyView();
+        identifyView.setMarshaller(marshaller);
+        
+        metaDataRecord = new CsvDemoMetaDataRecord(true, "/tmp", "");
+        config = CsvDemoExportConfigurator.NewInstance(null, null);
+
+        demoRecord = new CsvDemoRecord(metaDataRecord, config);
+
+        request = new MockHttpServletRequest();
+
+        serverURI = new URI("localhost");
+
+        request.setServerName(serverURI.toString());
+        request.setServerPort(8090);
+        response = new MockHttpServletResponse();
+    }
+
+
+    @Test
+    public void testGetRecordView() throws Exception {
+
+        Taxon taxon = Taxon.NewInstance(null, null);
+        taxon.setTitleCache("TitleCache", true);
+        taxon.setCreated(new DateTime());
+
+        demoRecord.setScientificName(taxon.getTitleCache());
+        demoRecord.setAuthorName("Author");
+        demoRecord.setDatasetName("Classification");
+        
+        ArrayList<CsvDemoRecord> recordList = new ArrayList<CsvDemoRecord>();
+        logger.info(recordList.size());
+        recordList.add(demoRecord);
+        recordList.add(demoRecord);
+        recordList.add(demoRecord);
+        logger.info(recordList.size());
+        logger.info(recordList.get(0).getScientificName());
+        model.put("csv", recordList);
+
+        request.setRequestURI("/cgi-bin/oai?verb=GetRecord&identifier=urn:lsid:example.org:taxonconcepts:1&metadataPrefix=oai_dc");
+        CsvFileDownloadView jview = new CsvFileDownloadView(new File("test"));
+        jview.render(model, request, response);
+//		System.out.println(new String(response.getContentAsByteArray()));
+    }
+
+}
