001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)TestTransformationImpl.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.engine.xslt;
030:
031: import junit.framework.*;
032: import com.sun.jbi.engine.xslt.framework.*;
033: import java.io.File;
034: import java.util.logging.Logger;
035: import javax.xml.transform.stream.StreamSource;
036: import javax.xml.transform.Source;
037: import javax.xml.transform.stream.StreamResult;
038: import javax.xml.transform.Result;
039: import javax.xml.transform.TransformerFactory;
040:
041: /**
042: * DOCUMENT ME!
043: *
044: * @author root
045: */
046: public class TestTransformationImpl extends TestCase {
047:
048: /**
049: * DOCUMENT ME!
050: */
051: private WorkManager mWorkManager;
052: /**
053: * DOCUMENT ME!
054: */
055: private TransformationImpl mTransformationImpl;
056: /**
057: * DOCUMENT ME!
058: */
059: private String mXslt;
060: /**
061: * DOCUMENT ME!
062: */
063: private String mBadXslt;
064: /**
065: * DOCUMENT ME!
066: */
067: private File mInput;
068: /**
069: * DOCUMENT ME!
070: */
071: private File mBadInput;
072: /**
073: * DOCUMENT ME!
074: */
075: private File mOutput;
076:
077: /**
078: * Creates a new TestTransformationImpl object.
079: *
080: * @param testName DOCUMENT ME!
081: */
082: public TestTransformationImpl(java.lang.String testName) {
083: super (testName);
084: }
085:
086: /**
087: * DOCUMENT ME!
088: *
089: * @return DOCUMENT ME!
090: */
091: public static Test suite() {
092: TestSuite suite = new TestSuite(TestTransformationImpl.class);
093: return suite;
094: }
095:
096: /**
097: * Sets up tests.
098: */
099: public void setUp() {
100: /*
101: mTransformationImpl = new TransformationImpl(6);
102: String srcroot = System.getProperty("junit.srcroot");
103:
104: try
105: {
106: mXslt = srcroot + "/engine/xslt/regress/data/test.xslt";
107: mBadXslt = srcroot + "/engine/xslt/regress/data/bad.xslt";
108: mInput= new File(srcroot + "/engine/xslt/regress/data/input.xml");
109: mBadInput= new File(srcroot + "/engine/xslt/regress/data/badinput.xml");
110: mOutput= new File (srcroot + "/engine/xslt/regress/data/output.xml");
111: mWorkManager = WorkManager.getWorkManager("xslt");
112: }
113: catch (Exception jbiException)
114: {
115: jbiException.printStackTrace();
116: fail("setUp failed");
117: }
118: try
119: {
120: mWorkManager.start();
121: }
122: catch (Exception ex)
123: {
124: //ex.printStackTrace();
125: }
126: */
127: }
128:
129: /**
130: * Test of getBean method, of class com.sun.jbi.engine.xslt.util.TransformationImpl.
131: */
132: public void testGetTransformerFactory() {
133: /*
134: System.out.println("testGetTransformerFactory");
135: TransformerFactory factory = TransformerFactory.newInstance();
136: TransformationImpl.putTransformerFactory(factory);
137: TransformerFactory factory2=TransformationImpl.getTransformerFactory();
138: assertNotNull("Retrieved factory is not Null", factory2);
139: assertEquals("putTransformerfactory failed", factory, factory2);
140: */
141: }
142:
143: /**
144: * Test of getEndpoint method, of class com.sun.jbi.engine.xslt.util.TransformationImpl.
145: */
146: public void testTransform() {
147: /*
148: System.out.println("testTransform");
149: Source input = (Source)new StreamSource(mInput);
150: Result output = (Result)new StreamResult(mOutput);
151: boolean result = false;
152: try
153: {
154: result = mTransformationImpl.doTransform(input, mXslt, output);
155: }
156: catch(Exception ex)
157: {
158: ex.printStackTrace();
159: }
160: assertTrue( "Transformation failed", result );
161: */
162: }
163:
164: /**
165: * Test of bad transformation for class com.sun.jbi.engine.xslt.util.TransformationImpl.
166: */
167: public void testBadInput() {
168: /*
169: System.out.println("testBadInput");
170: Source input = (Source)new StreamSource(mBadInput);
171: Result output = (Result)new StreamResult(mOutput);
172: boolean result = true;
173: try
174: {
175: result = mTransformationImpl.doTransform(input, mXslt ,output );
176: System.out.println("Test bad input" + result);
177: }
178: catch(Exception ex)
179: {
180: return;
181: }
182: assertFalse("Expected Transformation Failure" , result);
183: */
184: }
185:
186: /**
187: * Test of bad transformation for class com.sun.jbi.engine.xslt.util.TransformationImpl.
188: */
189: public void testBadXSLT() {
190: /*
191: System.out.println("testBadXSLT");
192: Source input = (Source)new StreamSource(mBadInput);
193: Result output = (Result)new StreamResult(mOutput);
194: boolean result = true;
195: try
196: {
197: result = mTransformationImpl.doTransform(input, mBadXslt ,output );
198: System.out.println("Test bad xslt" + result);
199: }
200: catch(Exception ex)
201: {
202: return;
203: }
204: assertFalse("Expected Transformation Failure" , result);
205: */
206: }
207:
208: /**
209: * Test of init method, of class com.sun.jbi.engine.xslt.util.TransformationImpl.
210: */
211: public void testInit() {
212: System.out.println("testInit");
213: }
214:
215: }
|