Last change
on this file since 1522 was
1522,
checked in by t.w.abma@…, 12 years ago
|
- initial Importer Wizard integration test with XML template file and NTC Study Excel file
|
File size:
1.7 KB
|
Line | |
---|
1 | package gscf |
---|
2 | |
---|
3 | import grails.test.* |
---|
4 | import org.springframework.core.io.* |
---|
5 | import grails.converters.* |
---|
6 | |
---|
7 | /** |
---|
8 | * ImporterTests Test |
---|
9 | * |
---|
10 | * Description of my test |
---|
11 | * |
---|
12 | * @author Tjeerd |
---|
13 | * @since 20110314 |
---|
14 | * @package gscf |
---|
15 | * |
---|
16 | * Revision information: |
---|
17 | * $Rev$ |
---|
18 | * $Author$ |
---|
19 | * $Date$ |
---|
20 | */ |
---|
21 | class ImporterTests extends GroovyTestCase { |
---|
22 | def ImporterService |
---|
23 | |
---|
24 | static final String testStudyExcelFile = "testfiles/NTC_Experiment_test4.xls" |
---|
25 | static final String testStudyXMLTemplateFile = "testfiles/ntc_tudy_template.xml" |
---|
26 | static final String testSheetIndex = "0" |
---|
27 | static final String testHeaderRow = "0" |
---|
28 | static final String testDatamatrixStart = "0" |
---|
29 | |
---|
30 | protected void setUp() { |
---|
31 | super.setUp() |
---|
32 | } |
---|
33 | |
---|
34 | protected void tearDown() { |
---|
35 | super.tearDown() |
---|
36 | } |
---|
37 | |
---|
38 | /** |
---|
39 | * Try to import an example Excel study and an XML study template |
---|
40 | */ |
---|
41 | void testImportExcelAndXMLTemplateStudy() { |
---|
42 | def xml |
---|
43 | |
---|
44 | // Load the files from a subfolder in the integration test folder and setup input streams |
---|
45 | Resource resourceExcel = new ClassPathResource(testStudyExcelFile, getClass().classLoader) |
---|
46 | Resource resourceXMLTemplate = new ClassPathResource(testStudyXMLTemplateFile, getClass().classLoader) |
---|
47 | |
---|
48 | // Create input streams from the resources |
---|
49 | def fisExcel = new FileInputStream(resourceExcel.getFile()) |
---|
50 | assert fisExcel |
---|
51 | |
---|
52 | def fisXML = new FileInputStream(resourceXMLTemplate.getFile()) |
---|
53 | assert fisXML |
---|
54 | |
---|
55 | // Retrieve the input stream as an Excel workbook |
---|
56 | def wb = importerService.getWorkbook(fisExcel) |
---|
57 | assert wb |
---|
58 | |
---|
59 | // Parse XML |
---|
60 | try { |
---|
61 | xml = XML.parse(fisXML, "UTF-8") |
---|
62 | } catch( Exception e ) { |
---|
63 | println "Parsing failed" + e |
---|
64 | } |
---|
65 | |
---|
66 | assert xml |
---|
67 | |
---|
68 | } |
---|
69 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.