1
2
3
4
5
6
7
8
9
10
11 package org.mule.transformers.xml;
12
13 import org.mule.umo.lifecycle.InitialisationException;
14 import org.mule.umo.transformer.UMOTransformer;
15 import org.mule.util.IOUtils;
16
17 public class XsltTransformerTestCase extends AbstractXmlTransformerTestCase
18 {
19
20 private String srcData;
21 private String resultData;
22
23
24 protected void doSetUp() throws Exception
25 {
26 srcData = IOUtils.getResourceAsString("cdcatalog.xml", getClass());
27 resultData = IOUtils.getResourceAsString("cdcatalog.html", getClass());
28 }
29
30 public UMOTransformer getTransformer() throws Exception
31 {
32 XsltTransformer transformer = new XsltTransformer();
33 transformer.setXslFile("cdcatalog.xsl");
34 transformer.setMaxActiveTransformers(42);
35 transformer.initialise();
36 return transformer;
37 }
38
39 public UMOTransformer getRoundTripTransformer() throws Exception
40 {
41 return null;
42 }
43
44
45 public void testRoundtripTransform() throws Exception
46 {
47
48 }
49
50 public Object getTestData()
51 {
52 return srcData;
53 }
54
55 public Object getResultData()
56 {
57 return resultData;
58 }
59
60 public void testCustomTransformerFactoryClass() throws InitialisationException
61 {
62 XsltTransformer t = new XsltTransformer();
63 t.setXslTransformerFactory("com.nosuchclass.TransformerFactory");
64 t.setXslFile("cdcatalog.xsl");
65
66 try
67 {
68 t.initialise();
69 fail("should have failed with ClassNotFoundException");
70 }
71 catch (InitialisationException iex)
72 {
73 assertEquals(ClassNotFoundException.class, iex.getCause().getClass());
74 }
75
76
77 t.setXslTransformerFactory(null);
78 t.initialise();
79 }
80
81
82 protected void doTestClone(UMOTransformer original, UMOTransformer clone) throws Exception
83 {
84 super.doTestClone(original, clone);
85
86 XsltTransformer t1 = (XsltTransformer) original;
87 XsltTransformer t2 = (XsltTransformer) clone;
88
89
90 assertNotSame("transformerPool", t1.transformerPool, t2.transformerPool);
91
92 assertEquals("transformerPool.maxActive", t1.getMaxActiveTransformers(), t2
93 .getMaxActiveTransformers());
94 }
95
96 }