1 19 20 package org.netbeans.tests.xml; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import java.io.PrintWriter ; 25 import java.io.StringWriter ; 26 import org.netbeans.jellytools.Bundle; 27 import org.netbeans.jellytools.ExplorerOperator; 28 import org.netbeans.jellytools.nodes.Node; 29 import org.netbeans.jemmy.JemmyProperties; 30 import org.netbeans.jemmy.operators.JTreeOperator; 31 import org.netbeans.jemmy.operators.Operator; 32 import org.netbeans.jemmy.util.Dumper; 33 import org.netbeans.jemmy.util.PNGEncoder; 34 35 36 40 public class JXTest extends XTest { 41 public static final String DELIM = "|"; 42 protected static boolean captureScreen = true; 43 protected static boolean dumpScreen = true; 44 45 46 47 public JXTest(String name) { 48 super(name); 49 boolean dbgTimeouts = Boolean.getBoolean(System.getProperty("xmltest.dbgTimeouts", "true")); 50 try { 51 if (dbgTimeouts) { 52 JemmyProperties.getCurrentTimeouts().loadDebugTimeouts(); 53 } 54 } catch (IOException ioe) { 55 log("Load Debug Timeouts fail.", ioe); 56 } 57 } 58 59 protected void fail(String msg, Exception e) { 60 StringWriter sw = new StringWriter (); 61 PrintWriter pw = new PrintWriter (sw); 62 e.printStackTrace(pw); 63 if (captureScreen) { 64 try { 65 PNGEncoder.captureScreen(getWorkDirPath()+File.separator+"screen.png"); 66 } catch (Exception e1) {} 67 } 68 if (dumpScreen) { 69 try { 70 Dumper.dumpAll(getWorkDirPath()+File.separator+"screen.xml"); 71 } catch (Exception e2) {} 72 } 73 fail(msg + "\n" + sw); 74 } 75 76 80 protected Node findDataNode(String path) { 81 Node node = null; 82 try { 83 String treePath = getFilesystemName() + DELIM + getDataPackageName(DELIM) + DELIM + path; 84 JTreeOperator tree = ExplorerOperator.invoke().repositoryTab().tree(); 85 tree.setComparator(new Operator.DefaultStringComparator(true, true)); 86 node = new Node(tree, treePath); 87 } catch (Exception ex) { 88 log("Cannot find data node: " + path, ex); 89 } 90 return node; 91 } 92 93 97 110 } 125 | Popular Tags |