1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.cdm.print;
|
11
|
|
12
|
import static org.junit.Assert.assertNotNull;
|
13
|
|
14
|
import java.io.IOException;
|
15
|
import java.io.InputStream;
|
16
|
import java.net.URL;
|
17
|
|
18
|
import javax.xml.transform.TransformerException;
|
19
|
|
20
|
import org.apache.log4j.Logger;
|
21
|
import org.jdom.Document;
|
22
|
import org.jdom.JDOMException;
|
23
|
import org.jdom.input.SAXBuilder;
|
24
|
import org.jdom.output.XMLOutputter;
|
25
|
import org.jdom.transform.XSLTransformException;
|
26
|
import org.junit.Before;
|
27
|
import org.junit.Ignore;
|
28
|
import org.junit.Test;
|
29
|
|
30
|
import eu.etaxonomy.cdm.print.Transformator;
|
31
|
import eu.etaxonomy.cdm.print.out.odf.OdfOutputModule;
|
32
|
import eu.etaxonomy.cdm.print.out.odf.OdfOutputModuleTest;
|
33
|
|
34
|
/**
|
35
|
* @author n.hoffmann
|
36
|
* @created Apr 20, 2010
|
37
|
* @version 1.0
|
38
|
*/
|
39
|
public class TransformatorTest {
|
40
|
private static final Logger logger = Logger
|
41
|
.getLogger(TransformatorTest.class);
|
42
|
private Document input;
|
43
|
|
44
|
/**
|
45
|
* @throws java.lang.Exception
|
46
|
*/
|
47
|
@Before
|
48
|
public void setUp() throws Exception {
|
49
|
|
50
|
InputStream documentStream = OdfOutputModuleTest.class.getResourceAsStream("single_input.xml");
|
51
|
|
52
|
SAXBuilder builder = new SAXBuilder();
|
53
|
input = builder.build(documentStream);
|
54
|
|
55
|
}
|
56
|
|
57
|
/**
|
58
|
* Test method for {@link eu.etaxonomy.cdm.print.Transformator#Transformator(java.io.InputStream)}.
|
59
|
* @throws XSLTransformException
|
60
|
* @throws IOException
|
61
|
*/
|
62
|
@Test
|
63
|
@Ignore
|
64
|
public void testTransformator() throws XSLTransformException, IOException {
|
65
|
URL stylesheet = TransformatorTest.class.getResource(OdfOutputModule.STYLESHEET_RESOURCE_DEFAULT);
|
66
|
new Transformator(stylesheet);
|
67
|
}
|
68
|
|
69
|
/**
|
70
|
* Test method for {@link eu.etaxonomy.cdm.print.Transformator#transform(org.jdom.Document)}.
|
71
|
* @throws JDOMException
|
72
|
* @throws TransformerException
|
73
|
* @throws IOException
|
74
|
*/
|
75
|
@Test
|
76
|
public void testTransform() throws IOException, TransformerException, JDOMException {
|
77
|
URL stylesheet = TransformatorTest.class.getResource(OdfOutputModule.STYLESHEET_RESOURCE_DEFAULT);
|
78
|
Transformator transformator = new Transformator(stylesheet);
|
79
|
|
80
|
Document output = transformator.transform(input);
|
81
|
|
82
|
XMLOutputter outputter = new XMLOutputter();
|
83
|
outputter.output(output, System.out);
|
84
|
|
85
|
assertNotNull("Output document should not be null", output);
|
86
|
}
|
87
|
}
|