package org.netbeans.jellytools.examples; import java.io.File; import org.netbeans.jellytools.JellyTestCase; import org.netbeans.jellytools.MainWindowOperator; import org.netbeans.jellytools.OutputWindowOperator; import org.netbeans.jellytools.nodes.JavaNode; import org.netbeans.jellytools.nodes.FilesystemNode; import org.netbeans.junit.NbTestSuite; /** Executes java class, checks status and output. * Requires that /sampledir/HelloWorld exists and has main method. * Run TestWizard and TestEditor to prepare HelloWorld class. */ public class TestOutput extends JellyTestCase { public TestOutput(java.lang.String testName) { super(testName); } public static void main(java.lang.String[] args) { junit.textui.TestRunner.run(suite()); } public static junit.framework.Test suite() { return new NbTestSuite(TestOutput.class); } public void testOutput() { //create a node for the sampledir directory FilesystemNode tmpNode = new FilesystemNode( System.getProperty("netbeans.user") + File.separator + "sampledir"); //create a node for the source JavaNode clNode = new JavaNode(tmpNode, "HelloWorld"); //execute clNode.execute(); //wait for a status in main window footer MainWindowOperator.getDefault().waitStatusText("Finished "); //create an operator for output window OutputWindowOperator output = OutputWindowOperator.invoke(); //select "HelloWorld" page and get a terminal from it //wait "Hello, world!" to be displayed output.getTerm("HelloWorld").waitText("Hello, world!"); //select "Compiler" page output.selectCompilerPage(); //check that "Finished" text displayed if(output.getText().indexOf("Finished ") == -1) { fail(); } } }