1 19 package org.netbeans.modules.xml.tools.generator; 20 21 import java.lang.reflect.Method ; 22 import junit.textui.TestRunner; 23 import org.netbeans.modules.xml.core.XMLDataObject; 24 import org.netbeans.modules.xml.tax.cookies.TreeEditorCookie; 25 import org.netbeans.tax.TreeDocument; 26 import org.netbeans.tax.TreeElement; 27 import org.netbeans.tests.xml.XTest; 28 import org.openide.filesystems.FileObject; 29 30 67 68 public class GenerateDTDSupportTest extends XTest { 69 70 71 public GenerateDTDSupportTest(String testName) { 72 super(testName); 73 } 74 75 public void test() throws Exception { 76 XMLDataObject dao = (XMLDataObject) TestUtil.THIS.findData("Node00.xml"); 77 if (dao == null) { 78 fail("\"data/Node00.xml\" data object is not found!"); 79 } 80 TreeEditorCookie cake = (TreeEditorCookie) dao.getCookie(TreeEditorCookie.class); 81 TreeElement element = ((TreeDocument)cake.openDocumentRoot()).getDocumentElement(); 82 FileObject primFile = dao.getPrimaryFile(); 83 String name = primFile.getName() + "_" + element.getQName(); 84 FileObject folder = primFile.getParent(); 85 String encoding = null; 86 try { 87 encoding = element.getOwnerDocument().getEncoding(); 88 } catch (NullPointerException e) { } 89 90 GenerateDTDSupport gen = new GenerateDTDSupport(dao); 91 Method m = gen.getClass().getDeclaredMethod("xml2dtd", new Class [] {String .class, String .class}); 93 m.setAccessible(true); 94 String result = (String ) m.invoke(gen, new Object [] {name, encoding}); 95 96 ref(result); 97 compareReferenceFiles(); 98 } 99 100 104 public static void main(String args[]) { 105 TestRunner.run(GenerateDTDSupportTest.class); 106 } 107 } 108 | Popular Tags |