Edit online

If you have developed complex custom plugins or frameworks (document types), the best way to test your implementation and ensure that further changes will not interfere with the current behavior is to make automated tests for your customization.

An Oxygen XML Author standalone installation includes a main oxygen.jar library located in the [OXYGEN_INSTALL_DIR]. That JAR library contains a base class for testing developer customizations named: ro.sync.exml.workspace.api.PluginWorkspaceTCBase.

To develop JUnit tests for your customizations using the Eclipse workbench, follow these steps:

  1. Create a new Eclipse Java project and copy the entire contents of the [OXYGEN_INSTALL_DIR] folder to the new project.
  2. Add all JAR libraries present in the [OXYGEN_INSTALL_DIR]/lib directory to the Java Build Path->Libraries tab. Make sure that the main JAR library oxygen.jar or oxygenAuthor.jar is the first one in the Java classpath by moving it up in the Order and Export tab.
  3. Click Add Library and add the JUnit and JFCUnit libraries.
  4. Create a new Java class that extends ro.sync.exml.workspace.api.PluginWorkspaceTCBase.
  5. Pass the following parameters to the constructor of the super class:
    • File installationFolder - The file path to the main application installation directory. If not specified, it defaults to the folder where the test is started.
    • File frameworksFolder - The file path to the frameworks directory. It can point to a custom framework directory where it resides.
    • File pluginsFolder - The file path to the plugins directory. It can point to a custom plugin directory where it resides.
    • File optionsFolder - The folder that contains the application options. If not specified, the application will auto-detect the location based on the started product ID.
    • String licenseKey - The license key used to license the test class.
    • int productID - The ID of the product and should be one of the following: PluginWorkspaceTCBase.XML_AUTHOR_PRODUCT, PluginWorkspaceTCBase.XML_EDITOR_PRODUCT, or PluginWorkspaceTCBase.XML_DEVELOPER_PRODUCT.
  6. Create test methods that use the API in the base class to open XML files and perform various actions on them. Your test class could look something like this:
    public class MyTestClass extends PluginWorkspaceTCBase {
     * Constructor.
    public MyTestClass() throws Exception {
    	super(null, new File("frameworks"), new File("plugins"), null, 
    "------START-LICENSE-KEY------\n" + 
    	"\n" + 
    	"Registration_Name=Developer\n" + 
    	"\n" + 
    	"Company=\n" + 
    	"\n" + 
    	"Category=Enterprise\n" + 
    	"\n" + 
    	"Component=XML-Editor, XSLT-Debugger, Saxon-SA\n" + 
    	"\n" + 
    	"Version=14\n" + 
    	"\n" + 
    	"Number_of_Licenses=1\n" + 
    	"\n" + 
    	"Date=09-04-2012\n" + 
    	"\n" + 
    	"Trial=31\n" + 
    	"\n" + 
    	"SGN=MCwCFGNoEGJSeiC3XCYIyalvjzHhGhhqAhRNRDpEu8RIWb8icCJO7HqfVP4++A\\=\\=\n" + 
    	"\n" + 
       * <p><b>Description:</b> TC for opening a file and using a bold operation</p>
       * <p><b>Bug ID:</b> EXM-20417</p>
       * @author radu_coravu
       * @throws Exception
    public void testOpenFileAndBoldEXM_20417() throws Exception {
          WSEditor ed = open(new File
    	    //Move caret
    	    moveCaretRelativeTo("Context", 1, false);
    	    //Insert <b>
    	    assertEquals("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + 
    	    		"<!DOCTYPE task PUBLIC \"-//OASIS//DTD DITA Task//EN\"
     \"http://docs.oasis-open.org/dita/v1.1/OS/dtd/task.dtd\">\n" + 
    	    		"<task id=\"taskId\">\n" + 
    	    		"    <title>Task <b>title</b></title>\n" + 
    	    		"    <prolog/>\n" + 
    	    		"    <taskbody>\n" + 
    	    		"        <context>\n" + 
    	    		"            <p>Context for the current task</p>\n" + 
    	    		"        </context>\n" + 
    	    		"        <steps>\n" + 
    	    		"            <step>\n" + 
    	    		"                <cmd>Task step.</cmd>\n" + 
    	    		"            </step>\n" + 
    	    		"        </steps>\n" + 
    	    		"    </taskbody>\n" + 
    	    		"</task>\n" + 
    	    		"", getCurrentEditorXMLContent());