source: trunk/test/integration/gscf/ImporterTests.groovy @ 1525

Last change on this file since 1525 was 1525, checked in by t.w.abma@…, 10 years ago
  • Importer tests on hold due to missing parse() method in Template domain
  • ImportMappings? and MappingColumns? are now persisted and can be loaded, todo: null-entities? and lazy loading issue
File size: 2.0 KB
Line 
1package gscf
2
3import grails.test.*
4import org.springframework.core.io.*
5import grails.converters.*
6import dbnp.authentication.*
7import org.dbnp.gdt.*
8
9/**
10 * ImporterTests Test
11 *
12 * Description of my test
13 *
14 * @author  Tjeerd
15 * @since       20110314
16 * @package     gscf
17 *
18 * Revision information:
19 * $Rev$
20 * $Author$
21 * $Date$
22 */
23class ImporterTests extends GroovyTestCase {
24    def ImporterService
25
26    static final String testStudyExcelFile = "testfiles/NTC_Experiment_test4.xls"
27    static final String testStudyXMLTemplateFile = "testfiles/ntc_tudy_template.xml"
28    static final String testSheetIndex = "0"
29    static final String testHeaderRow = "0"
30    static final String testDatamatrixStart = "0"
31   
32    protected void setUp() {
33        super.setUp()
34    }
35
36    protected void tearDown() {
37        super.tearDown()
38    }
39
40    /**
41    * Try to import an example Excel study and an XML study template
42    */
43    void testImportExcelAndXMLTemplateStudy() {
44        def xmltemplate
45        def user = SecUser.findByUsername( "user" );
46       
47        // Load the files from a subfolder in the integration test folder and setup input streams
48        Resource resourceExcel = new ClassPathResource(testStudyExcelFile, getClass().classLoader)
49        Resource resourceXMLTemplate = new ClassPathResource(testStudyXMLTemplateFile, getClass().classLoader)
50
51        // Create input streams from the resources
52        def fisExcel = new FileInputStream(resourceExcel.getFile())
53        assert fisExcel
54
55        def fisXML = new FileInputStream(resourceXMLTemplate.getFile())
56        assert fisXML
57
58        // Retrieve the input stream as an Excel workbook
59        def wb = importerService.getWorkbook(fisExcel)
60        assert wb
61
62        // Parse XML
63                try {
64                        xmltemplate = XML.parse(fisXML, "UTF-8")
65                } catch( Exception e ) {
66                        println "Parsing failed" + e
67                }
68
69        assert xmltemplate
70
71        xmltemplate.template.each {
72            println it
73        }
74
75        // Parse the XML template
76        def t = Template.parse(xmltemplate.template, user);
77
78        assert t
79    }
80}
Note: See TracBrowser for help on using the repository browser.