1 19 package org.netbeans.xml.test.core; 20 21 import java.awt.event.KeyEvent ; 22 import java.io.IOException ; 23 import junit.framework.Test; 24 import junit.framework.TestSuite; 25 import junit.textui.TestRunner; 26 import org.netbeans.jellytools.Bundle; 27 import org.netbeans.jellytools.EditorOperator; 28 import org.netbeans.jellytools.NewFileWizardOperator; 29 import org.netbeans.junit.NbTestSuite; 30 import org.netbeans.xml.test.core.wizardoperator.DTDOptionsWizardOperator; 31 import org.netbeans.xml.test.core.wizardoperator.NewXMLFileTestTypeWizardOperator; 32 import org.netbeans.xml.test.core.wizardoperator.NewXMLFileWizardOperator; 33 import org.netbeans.xml.test.core.wizardoperator.XSDOptionsWizardOperator; 34 35 65 66 70 public class CoreTemplatesTest extends XMLTest { 71 72 protected static boolean DEBUG = false; 73 private static final String packageName = "pack"; 74 private static final String folder = "web"; 75 private static final String projectName = "CoreTemplatesTestProject"; 76 private static final String category = Bundle.getString(CORE_BUNDLE, "OpenIDE-Module-Display-Category"); 77 private static final String wizardTitle = Bundle.getString(UI_BUNDLE, "LBL_NewFileWizard_Title"); 78 private static final int WELL_FORMED = 0; 79 private static final int DTD_FORMED = 1; 80 private static final int XSD_FORMED = 2; 81 private boolean generateGoldenFiles = false; 82 83 84 85 86 public CoreTemplatesTest(String testName) { 87 super(testName); 88 } 89 90 92 public void testNewXML() throws Exception { 93 create(WELL_FORMED); 94 } 95 96 public void testNewXMLDTDFormed() throws Exception { 97 create(DTD_FORMED); 98 } 99 100 public void testNewXMLXSDFormed() throws Exception { 101 create(XSD_FORMED); 102 } 103 104 public void testNewDTD() throws Exception { 105 NewFileWizard(Bundle.getString(CORE_BUNDLE, "Templates/XML/emptyDTD.dtd"), false); 106 } 107 108 public void testNewXMLSchema() throws Exception { 109 NewFileWizard(Bundle.getString(XMLSchema_BUNDLE, "Templates/XML/XMLSchema.xsd"), false); 110 } 111 112 public void testNewCSS() throws Exception { 113 NewFileWizard(Bundle.getString(CSS_BUNDLE, "Templates/XML/CascadeStyleSheet.css"), false); 114 } 115 116 public void testNewXSLStyleSheet() throws Exception { 117 NewFileWizard(Bundle.getString(CORE_BUNDLE, "Templates/XML/StyleSheet.xsl"), false); 118 } 119 120 public void testNewXMLEntity() throws Exception { 121 NewFileWizard(Bundle.getString(CORE_BUNDLE, "Templates/XML/xml_entity.ent"), false); 122 } 123 124 125 127 private void NewFileWizard(String fileType, boolean next) throws IOException { 128 String fileName = this.getName(); 129 NewFileWizardOperator nfwo = NewFileWizardOperator.invoke(wizardTitle); 130 nfwo.selectProject(projectName); 131 nfwo.selectCategory(category); 132 nfwo.selectFileType(fileType); 133 nfwo.next(); 134 NewXMLFileWizardOperator op = new NewXMLFileWizardOperator("New " + fileType); 135 op.folder().setText(folder); 136 op.fileName().setText(fileName); 137 if (next) op.next(); 138 else{ 139 op.finish(); 140 removeComment(); 141 ending(); 142 } 143 } 144 145 146 private void create(int formed) throws IOException { 147 String fileType =Bundle.getString(CORE_BUNDLE, "Templates/XML/XMLDocument.xml"); 149 NewFileWizard(fileType, true); 150 NewXMLFileTestTypeWizardOperator ttOp = new NewXMLFileTestTypeWizardOperator(); 151 switch (formed){ 152 case WELL_FORMED: 153 ttOp.wellFormed().clickMouse(); 154 ttOp.finish(); 155 break; 156 case XSD_FORMED: 157 ttOp.xsdFormed().clickMouse(); 158 ttOp.next(); 159 XSDOptionsWizardOperator opXSD = new XSDOptionsWizardOperator(); 160 opXSD.rootElement().typeText("basic"); 161 opXSD.namespace().typeText("namespace"); 162 opXSD.namespace().pushKey(KeyEvent.VK_TAB); 163 opXSD.uri().setText("soubor.xsd"); 164 opXSD.finish(); 165 break; 166 case DTD_FORMED: 167 ttOp.dtdFormed().clickMouse(); 168 ttOp.next(); 169 DTDOptionsWizardOperator opDTD = new DTDOptionsWizardOperator(); 170 opDTD.publicID().selectItem("-//NetBeans//DTD Mode Properties 2.2//EN"); 171 opDTD.systemID().typeText("systemID"); 172 opDTD.documentRoot().selectItem(1); 173 opDTD.finish(); 174 break; 175 } 176 removeComment(); 177 ending(); 178 } 179 180 private void removeComment(){ 181 String author = "Author.*"; 182 String created = "Created.*"; 183 EditorOperator eo = new EditorOperator(this.getName()); 184 String text = eo.getText(); 185 186 text = text.replaceFirst(author, author); 189 text = text.replaceFirst(created, created); 193 ref(text); 195 } 196 197 public boolean generateGoldenFiles(){ 198 return generateGoldenFiles; 199 } 200 201 203 public static Test suite() { 204 TestSuite suite = new NbTestSuite(); 205 initialization(projectName); 206 suite.addTest(new CoreTemplatesTest("testNewXML")); 207 suite.addTest(new CoreTemplatesTest("testNewXMLDTDFormed")); 208 suite.addTest(new CoreTemplatesTest("testNewXMLXSDFormed")); 209 suite.addTest(new CoreTemplatesTest("testNewDTD")); 210 suite.addTest(new CoreTemplatesTest("testNewXMLSchema")); 211 suite.addTest(new CoreTemplatesTest("testNewXSLStyleSheet")); 212 suite.addTest(new CoreTemplatesTest("testNewXMLEntity")); 213 suite.addTest(new CoreTemplatesTest("testNewCSS")); 214 return suite; 215 } 216 217 public static void main(String [] args) throws Exception { 218 TestRunner.run(suite()); 221 } 222 223 } 224 | Popular Tags |