1 19 package org.netbeans.modules.xsl.action; 20 21 import java.awt.event.KeyEvent ; 22 import junit.framework.Test; 23 import junit.framework.TestSuite; 24 import junit.textui.TestRunner; 25 import org.netbeans.jellytools.EditorOperator; 26 import org.netbeans.jellytools.EditorWindowOperator; 27 import org.netbeans.jellytools.actions.OpenAction; 28 import org.netbeans.jellytools.modules.xml.XSLTransformationDialog; 29 import org.netbeans.jellytools.modules.xsl.actions.TransformAction; 30 import org.netbeans.jellytools.nodes.Node; 31 import org.netbeans.junit.NbTestSuite; 32 import org.netbeans.tests.xml.JXTest; 33 import org.openide.loaders.DataObject; 34 35 36 37 public class TransformationActionTest extends JXTest { 38 39 40 public TransformationActionTest(String testName) { 41 super(testName); 42 } 43 44 46 47 public void testTransformation() throws Exception { 48 49 final String OUT_FILE = "../out/document.html"; 50 final String OUT_NODE = "out" + DELIM + "document"; 52 54 DataObject dao = TestUtil.THIS.findData("out/document.html"); 56 if (dao != null) dao.delete(); 57 XSLTransformationDialog dialog = transformXML("sources" + DELIM + "document"); 58 59 dialog.cboXSLTScript().clearText(); 61 dialog.cboXSLTScript().typeText("../styles/doc2html.xsl"); 62 dialog.cboXSLTScript().pressKey(KeyEvent.VK_TAB); 63 64 dialog.cboOutput().clearText(); 65 dialog.cboOutput().typeText(OUT_FILE); 66 dialog.cboJComboBox().selectItem(dialog.ITEM_DONOTHING); 67 dialog.oK(); 68 69 char[] cbuf = new char[4000]; 71 Node htmlNode = findDataNode(OUT_NODE); 72 new OpenAction().perform(htmlNode); 73 EditorWindowOperator ewo = new EditorWindowOperator(); 75 EditorOperator eo = ewo.getEditor(htmlNode.getText()); 76 eo.setCaretPositionToLine(1); 77 eo.insert("\n"); 78 eo.waitModified(true); 79 eo.deleteLine(1); 80 eo.save(); 81 82 String substring = "<h1>Testing Document</h1>"; 83 boolean result = eo.getText().indexOf(substring) != -1; 84 assertTrue("Cannot find control substring:\n" + substring, (result)); 85 } 87 88 89 public void testTransformationDialog() throws Exception { 90 XSLTransformationDialog dialog = transformXML("sources" + DELIM + "document"); 92 dialog.verify(); 93 dialog.close(); 94 } 95 96 98 102 private XSLTransformationDialog transformXML(String path) throws Exception { 103 TransformAction transform = new TransformAction(); 104 transform.perform(findDataNode(path)); 105 XSLTransformationDialog dialog = new XSLTransformationDialog(); 106 dialog.activate(); 107 return dialog; 108 } 109 110 112 public static Test suite() { 113 TestSuite suite = new NbTestSuite(); 114 suite.addTest(new TransformationActionTest("testTransformationDialog")); 115 suite.addTest(new TransformationActionTest("testTransformation")); 116 return suite; 117 } 118 119 public static void main(String [] args) throws Exception { 120 System.setProperty("xmltest.dbgTimeouts", "true"); 121 TestRunner.run(suite()); 123 } 124 } 125 | Popular Tags |