Java Code Examples for org.netbeans.jemmy.JemmyException#printStackTrace()
The following examples show how to use
org.netbeans.jemmy.JemmyException#printStackTrace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: testCCClever.java From netbeans with Apache License 2.0 | 5 votes |
public void CleverTryCatch() throws Exception { startTest(); EditorOperator eoPHP = new EditorOperator("index.php"); new EventTool().waitNoEvent(1000); eoPHP.setCaretPosition("// put your code here", false); TypeCode(eoPHP, "\n"); TypeCode(eoPHP, "try{}catch("); ArrayList<String> cc = new ArrayList<String>(); CompletionJListOperator comp = null; try { comp = CompletionJListOperator.showCompletion(); } catch (JemmyException e) { log("EE: The CC window did not appear"); e.printStackTrace(getLog()); } if (comp != null) { Iterator items = comp.getCompletionItems().iterator(); while (items.hasNext()) { Object next = items.next(); if (next instanceof CompletionItem) { CompletionItem cItem = (CompletionItem) next; cc.add(((String) cItem.getSortText()).toLowerCase()); } } CompletionJListOperator.hideAll(); int counter = 0; for (int i = 0; i < cc.size(); i++) { if (cc.get(i).endsWith("exception") || cc.get(i).endsWith("fault")) { counter++; } } assertEquals("Unexpected number of items in code completion", cc.size(), counter); } else { throw new AssertionError("No items in cc list"); } endTest(); }
Example 2
Source File: CompletionTest.java From netbeans with Apache License 2.0 | 4 votes |
protected void exec(JEditorPane editor, TestStep step) throws Exception { try { BaseDocument doc = (BaseDocument) editor.getDocument(); ref(step.toString()); Caret caret = editor.getCaret(); caret.setDot(step.getOffset() + 1); EditorOperator eo = new EditorOperator(testFileObj.getNameExt()); eo.insert(step.getPrefix()); if (!isJavaScript()) { caret.setDot(step.getCursorPos()); } waitTypingFinished(doc); CompletionJListOperator comp = null; boolean print = false; int counter = 0; while (!print) { ++counter; if (counter > 5) { print = true; } try { comp = CompletionJListOperator.showCompletion(); } catch (JemmyException e) { log("EE: The CC window did not appear"); e.printStackTrace(getLog()); } if (comp != null) { print = dumpCompletion(comp, step, editor, print) || print; waitTypingFinished(doc); CompletionJListOperator.hideAll(); if (!print) {// wait for refresh Thread.sleep(1000); if (!isJavaScript()) { caret.setDot(step.getCursorPos()); } } } else { long time = System.currentTimeMillis(); String screenFile = time + "-screen.png"; log("CompletionJList is null"); log("step: " + step); log("captureScreen:" + screenFile); try { PNGEncoder.captureScreen(getWorkDir().getAbsolutePath() + File.separator + screenFile); } catch (Exception e1) { e1.printStackTrace(getLog()); } } } waitTypingFinished(doc); int rowStart = Utilities.getRowStart(doc, step.getOffset() + 1); int rowEnd = Utilities.getRowEnd(doc, step.getOffset() + 1); String fullResult = doc.getText(new int[]{rowStart, rowEnd}); String result = fullResult.trim(); int removed_whitespaces = fullResult.length() - result.length(); if (!result.equals(step.getResult().trim())) { ref("EE: unexpected CC result:\n< " + result + "\n> " + step.getResult()); } ref("End cursor position = " + (caret.getDot() - removed_whitespaces)); } finally { // undo all changes final UndoAction ua = SystemAction.get(UndoAction.class); assertNotNull("Cannot obtain UndoAction", ua); while (ua.isEnabled()) { runInAWT(new Runnable() { public void run() { ua.performAction(); } }); } } }