What this is
This file is included in the DevDaily.com
"Java Source Code
Warehouse" project. The intent of this project is to help you "Learn
Java by Example" TM.
Other links
The source code
/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License
* Version 1.0 (the "License"). You may not use this file except in
* compliance with the License. A copy of the License is available at
* http://www.sun.com/
*
* The Original Code is NetBeans. The Initial Developer of the Original
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2002 Sun
* Microsystems, Inc. All Rights Reserved.
*/
package org.netbeans.modules.xml.text.syntax;
import org.openide.execution.NbfsURLConnection;
import org.openide.loaders.DataFolder;
import org.netbeans.tax.*;
import org.netbeans.modules.xml.core.DTDDataObject;
import org.openide.cookies.SaveCookie;
import org.openide.cookies.EditorCookie;
import org.netbeans.modules.xml.core.XMLDataObject;
import org.openide.nodes.CookieSet;
import javax.swing.text.Document;
import org.netbeans.modules.editor.NbEditorDocument;
import org.netbeans.editor.SyntaxSupport;
import org.netbeans.modules.xml.text.syntax.XMLSyntaxSupport;
import org.netbeans.editor.TokenID;
import org.netbeans.editor.BaseDocument;
import org.netbeans.editor.ext.ExtSyntaxSupport;
import org.netbeans.editor.TokenItem;
import org.netbeans.tests.xml.XTest;
import org.openide.loaders.DataObject;
/**
*
*
*
*
* XML Module API Test: CreateSimpleXML
*
*
*
What it tests:
*
* This test creates simple XML document with DTD and writes it into output.
*
*
How it works:
*
* 1) create empty XML document from template
* 2) create new Document Type and add it into document
* 3) append XML elements
* 4) write the document into output
*
*
Settings:
* none
*
*
Output (Golden file):
* XML document with DTD.
*
* To Do:
* none
*
* Created on December 20, 2000, 12:33 PM
*
*/
public class ColoringTest extends XTest {
private static String XML_TEMPLATE = "XML/XMLwithDTD.xml";
private static String DOCUMENT_NAME = "Books";
private static String DTD_SYS_ID = "simple.dtd";
private static String INTERNAL_DTD = "internalDTD.dtd";
private static int TREE_LEVELS = 3;
/** Creates new CoreSettingsTest */
public ColoringTest(String testName) {
super(testName);
}
// TESTS ///////////////////////////////////////////////////////////////////
public void testXMLColoring() throws Exception {
dumpTokens("XMLColoring", "xml");
}
public void testDTDColoring() throws Exception {
dumpTokens("DTDColoring", "dtd");
}
public void testCSSColoring() throws Exception {
dumpTokens("CSSColoring", "css");
}
// LIBS ////////////////////////////////////////////////////////////////////
public void dumpTokens(String fileName, String ext) throws Exception {
String pkgName = getClass().getPackage().getName();
DataObject obj = TestUtil.THIS.findDataObject(pkgName + ".data", fileName, ext);
EditorCookie ed = (EditorCookie) obj.getCookie(EditorCookie.class);
BaseDocument doc = (BaseDocument) ed.openDocument();
ExtSyntaxSupport ess = (ExtSyntaxSupport) doc.getSyntaxSupport();
TokenItem token = ess.getTokenChain(0, doc.getLength());
while (token != null) {
TokenID tokenID = token.getTokenID();
ref(tokenID.getName()+ ": " + token.getImage());
token = token.getNext();
}
compareReferenceFiles();
}
// MAIN ////////////////////////////////////////////////////////////////////
/**
* Performs this testsuite.
* @param args the command line arguments
*/
public static void main(String args[]) {
junit.textui.TestRunner.run(ColoringTest.class);
}
}
|