1 19 20 package gui.action; 21 22 import java.util.HashMap ; 23 import org.netbeans.jellytools.EditorOperator; 24 import org.netbeans.jellytools.ProjectsTabOperator; 25 import org.netbeans.jellytools.TopComponentOperator; 26 import org.netbeans.jellytools.actions.SaveAllAction; 27 import org.netbeans.jellytools.nodes.Node; 28 import org.netbeans.jellytools.nodes.ProjectRootNode; 29 30 import org.netbeans.jemmy.operators.ComponentOperator; 31 import org.netbeans.jemmy.operators.JPopupMenuOperator; 32 import org.netbeans.jemmy.operators.JTreeOperator; 33 import org.netbeans.jemmy.operators.Operator; 34 import org.netbeans.modules.editor.java.JavaKit; 35 import org.netbeans.modules.editor.options.BaseOptions; 36 37 42 public class OpenJ2EEFiles extends org.netbeans.performance.test.utilities.PerformanceTestCase { 43 44 45 public static Node openNode ; 46 47 48 public static String fileProject; 49 50 51 public static String filePath; 52 53 54 public static String editorTitle; 55 56 57 public static String menuItem; 58 59 protected static String OPEN = org.netbeans.jellytools.Bundle.getStringTrimmed("org/openide/actions/Bundle", "Open"); 60 61 protected static String EDIT = org.netbeans.jellytools.Bundle.getStringTrimmed("org/openide/actions/Bundle", "Edit"); 62 63 67 public OpenJ2EEFiles(String testName) { 68 super(testName); 69 expectedTime = WINDOW_OPEN; 70 } 71 72 77 public OpenJ2EEFiles(String testName, String performanceDataName) { 78 super(testName, performanceDataName); 79 expectedTime = WINDOW_OPEN; 80 } 81 82 public void testOpeningJava(){ 83 WAIT_AFTER_OPEN = 4000; 84 setJavaEditorCaretFilteringOn(); 86 fileProject = "TestApplication-EJBModule"; 87 filePath = "Source Packages|test|TestSessionRemote.java"; 88 editorTitle = "TestSessionRemote.java"; 89 menuItem = OPEN; 90 repaintManager().setOnlyEditor(true); 91 doMeasurement(); 92 } 93 94 public void testOpeningSessionBean(){ 95 WAIT_AFTER_OPEN = 4000; 96 setJavaEditorCaretFilteringOn(); 98 fileProject = "TestApplication-EJBModule"; 99 filePath = "Enterprise Beans|TestSessionSB"; 100 editorTitle = "TestSessionBean.java"; 101 menuItem = OPEN; 102 repaintManager().setOnlyEditor(true); 103 doMeasurement(); 104 } 105 106 public void testOpeningEntityBean(){ 107 WAIT_AFTER_OPEN = 4000; 108 setJavaEditorCaretFilteringOn(); 110 fileProject = "TestApplication-EJBModule"; 111 filePath = "Enterprise Beans|TestEntityEB"; 112 editorTitle = "TestEntityBean.java"; 113 menuItem = OPEN; 114 repaintManager().setOnlyEditor(true); 115 doMeasurement(); 116 } 117 118 public void testOpeningEjbJarXml(){ 119 WAIT_AFTER_OPEN = 3000; 120 setJavaEditorCaretFilteringOn(); 122 fileProject = "TestApplication-EJBModule"; 123 filePath = "Configuration Files|ejb-jar.xml"; 124 editorTitle = "ejb-jar.xml"; 125 menuItem = OPEN; 126 repaintManager().setOnlyEditor(false); 127 doMeasurement(); 128 } 129 130 public void testOpeningSunEjbJarXml(){ 131 WAIT_AFTER_OPEN = 3000; 132 setJavaEditorCaretFilteringOn(); 134 fileProject = "TestApplication-EJBModule"; 135 filePath = "Configuration Files|sun-ejb-jar.xml"; 136 editorTitle = "sun-ejb-jar.xml"; 137 menuItem = OPEN; 138 repaintManager().setOnlyEditor(false); 139 doMeasurement(); 140 } 141 142 public void testOpeningApplicationXml(){ 143 WAIT_AFTER_OPEN = 2000; 144 setJavaEditorCaretFilteringOn(); 146 fileProject = "TestApplication"; 147 filePath = "Configuration Files|application.xml"; 148 editorTitle = "application.xml"; 149 menuItem = EDIT; 150 repaintManager().setOnlyEditor(true); 151 doMeasurement(); 152 } 153 154 public void testOpeningSunApplicationXml(){ 155 WAIT_AFTER_OPEN = 2000; 156 setJavaEditorCaretFilteringOn(); 158 fileProject = "TestApplication"; 159 filePath = "Configuration Files|sun-application.xml"; 160 editorTitle = "sun-application.xml"; 161 menuItem = OPEN; 162 repaintManager().setOnlyEditor(false); 163 doMeasurement(); 164 } 165 166 public void initialize(){ 167 EditorOperator.closeDiscardAll(); 169 BaseOptions options = BaseOptions.getOptions(JavaKit.class); 170 options.setStatusBarCaretDelay(0); 171 HashMap props = new HashMap (); 172 props.put(org.netbeans.editor.SettingsNames.CODE_FOLDING_ENABLE, Boolean.FALSE); 173 options.setCodeFoldingProps(props); 174 179 } 180 181 public void shutdown(){ 182 repaintManager().setOnlyEditor(false); 183 EditorOperator.closeDiscardAll(); 184 } 185 186 public void prepare(){ 187 JTreeOperator tree = new ProjectsTabOperator().tree(); 188 tree.setComparator(new Operator.DefaultStringComparator(true, true)); 189 this.openNode = new Node(new ProjectRootNode(tree, fileProject), filePath); 190 191 if (this.openNode == null) { 192 throw new Error ("Cannot find node ["+ filePath + "] in project [" + fileProject + "]"); 193 } 194 log("========== Open file path ="+this.openNode.getPath()); 195 } 196 197 public ComponentOperator open(){ 198 JPopupMenuOperator popup = this.openNode.callPopup(); 199 if (popup == null) { 200 throw new Error ("Cannot get context menu for node ["+ filePath + "] in project [" + fileProject + "]"); 201 } 202 log("------------------------- after popup invocation ------------"); 203 try { 204 popup.pushMenu(this.menuItem); 205 } 206 catch (org.netbeans.jemmy.TimeoutExpiredException tee) { 207 throw new Error ("Cannot push menu item "+this.menuItem+" of node ["+ filePath + "] in project [" + fileProject + "]"); 208 } 209 log("------------------------- after open ------------"); 210 return new TopComponentOperator(this.editorTitle); 211 } 212 213 public void close(){ 214 if (testedComponentOperator != null) { 215 new SaveAllAction().performAPI(); 217 ((TopComponentOperator)testedComponentOperator).close(); 218 225 } 226 else { 227 throw new Error ("no component to close"); 228 } 229 } 230 231 } 232 | Popular Tags |