org.netbeans.jemmy.JemmyException Java Examples

The following examples show how to use org.netbeans.jemmy.JemmyException. 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: ActionNoBlock.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * performs action through popup menu
 *
 * @param component component to be action performed on
 * @throws UnsupportedOperationException when action does not support popup
 * mode
 */
@Override
public void performPopup(ComponentOperator component) {
    if (popupPath == null) {
        throw new UnsupportedOperationException(getClass().toString() + " does not define popup path");
    }
    // Need to wait here to be more reliable.
    // TBD - It can be removed after issue 23663 is solved.
    new EventTool().waitNoEvent(500);
    component.clickForPopup();
    JPopupMenuOperator popup = new JPopupMenuOperator(component);
    popup.setComparator(getComparator());
    popup.pushMenuNoBlock(popupPath, "|");
    try {
        Thread.sleep(AFTER_ACTION_WAIT_TIME);
    } catch (Exception e) {
        throw new JemmyException("Sleeping interrupted", e);
    }
}
 
Example #2
Source File: ProgressOperator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Wait process with given name finished.
 */
public static void waitFinished(final String name, long timeout) {
    try {
        Waiter waiter = new Waiter(new Waitable() {
            public Object actionProduced(Object anObject) {
                return processInProgress(name) ? null : Boolean.TRUE;
            }
            public String getDescription() {
                return("Wait process "+name+" is finished.");
            }
        });
        waiter.getTimeouts().setTimeout("Waiter.WaitingTime", timeout);
        waiter.waitAction(null);
    } catch (InterruptedException e) {
        throw new JemmyException("Interrupted.", e);
    }

}
 
Example #3
Source File: ProfilerValidationTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Waits until profiler is not stopped.
 */
private void waitProfilerStopped() {
    try {
        new Waiter(new Waitable() {
            @Override
            public Object actionProduced(Object object) {
                final int state = Profiler.getDefault().getProfilingState();
                final int mode = Profiler.getDefault().getProfilingMode();
                if ((state == Profiler.PROFILING_PAUSED) || (state == Profiler.PROFILING_RUNNING)) {
                    if (mode == Profiler.MODE_PROFILE) {
                        return null;
                    }
                }
                return Boolean.TRUE;
            }

            @Override
            public String getDescription() {
                return ("Wait profiler stopped."); // NOI18N
            }
        }).waitAction(null);
    } catch (InterruptedException ex) {
        throw new JemmyException("Waiting for profiler stopped failed.", ex);
    }
}
 
Example #4
Source File: Utilities.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Mounts <userdir>/sampledir through API
 * @return absolute path of mounted dir
 */
public static boolean mountSampledir() {
    String userdir = System.getProperty("netbeans.user"); // NOI18N
    String mountPoint = userdir+File.separator+"sampledir"; // NOI18N
    mountPoint = mountPoint.replace('\\', '/');
    FileSystem fs = Repository.getDefault().findFileSystem(mountPoint);
    if (fs == null) {
        try {
            LocalFileSystem lfs= new LocalFileSystem();
            lfs.setRootDirectory(new File(mountPoint));
            Repository.getDefault().addFileSystem(lfs);
            return true;
        } catch (IOException ioe) {
            throw new JemmyException("Mounting FS: "+mountPoint+" failed.", ioe);
        } catch (PropertyVetoException pve) {
            throw new JemmyException("Mounting FS: "+mountPoint+" failed.", pve);
        }
    }
    return true;
}
 
Example #5
Source File: ImportWizardOperator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Goes through the wizard and fill supplied parameter.
 * @param cvsRoot CVS root.
 * @param password password - can be null
 * @param folderToImport local folder to import
 * @param importMessage import message
 * @param repositoryFolder repository folder
 */
public void doImport(String repositoryURL, String password, String importMessage, String repositoryFolder) {
    if(repositoryURL == null) {
        throw new JemmyException("CVS root must not be null."); // NOI18N
    }
    if(importMessage == null) {
        throw new JemmyException("Import message must not be null."); // NOI18N
    }
    if(repositoryFolder == null) {
        throw new JemmyException("Repository Folder must not be null."); // NOI18N
    }
    ImportWizardOperator.invoke();
    RepositoryStepOperator rso = new RepositoryStepOperator();
    if(password != null) {
        rso.setPassword(password);
    }
    rso.setRepositoryURL(repositoryURL);
    rso.next();
    FolderToImportStepOperator folderToImportOper = new FolderToImportStepOperator();
    folderToImportOper.setImportMessage(importMessage);
    folderToImportOper.setRepositoryFolder(repositoryFolder);
    folderToImportOper.finish();
}
 
Example #6
Source File: OutputTabOperator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Returns text from this output tab.
 * @return text from this output tab.
 */
public String getText() {
    final int length = getLength();
    return (String) runMapping(new MapAction("getText") {

        @Override
        public Object map() {
            Document document = documentForTab(getSource());
            try {
                if (getOutputDocumentClass().isInstance(document)) {
                    Method getTextMethod = getOutputDocumentClass().getDeclaredMethod("getText", new Class[]{int.class, int.class});
                    getTextMethod.setAccessible(true);
                    return getTextMethod.invoke(document, new Object[]{Integer.valueOf(0), Integer.valueOf(length)}).toString();
                }
            } catch (Exception e) {
                throw new JemmyException("Getting text by reflection failed.", e);
            }
            return "";
        }
    });
}
 
Example #7
Source File: RefactoringTestCase.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected void openProject(String projectName) {
    if (pto == null) {
        pto = ProjectsTabOperator.invoke();
    }

    if (testProjectRootNode == null) {
        try {
            openDataProjects("projects/" + projectName);
            testProjectRootNode = pto.getProjectRootNode(projectName);
            testProjectRootNode.select();
        } catch (IOException ex) {
            throw new JemmyException("Open project [" + projectName + "] fails !!!", ex);
        }
    } else {
        log("Project is opened!");
    }
}
 
Example #8
Source File: WsValidation.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected void waitForTextInEditor(final EditorOperator eo, final String text) {
    try {
        new Waiter(new Waitable() {
            @Override
            public Object actionProduced(Object obj) {
                return eo.contains(text) ? Boolean.TRUE : null; //NOI18N
            }

            @Override
            public String getDescription() {
                return ("Editor contains " + text); //NOI18N
            }
        }).waitAction(null);
    } catch (InterruptedException ie) {
        throw new JemmyException("Interrupted.", ie); //NOI18N
    }
}
 
Example #9
Source File: CheckboxOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Changes selection if necessary. Uses a ButtonDriver registered for this
 * operator.
 *
 * @param newValue a button selection.
 */
public void changeSelection(boolean newValue) {
    makeComponentVisible();
    if (getState() != newValue) {
        try {
            waitComponentEnabled();
        } catch (InterruptedException e) {
            throw (new JemmyException("Interrupted!", e));
        }
        output.printLine("Change checkbox selection to " + (newValue ? "true" : "false")
                + "\n    :" + toStringSource());
        output.printGolden("Change checkbox selection to " + (newValue ? "true" : "false"));
        driver.push(this);
        if (getVerification()) {
            waitSelected(newValue);
        }
    }
}
 
Example #10
Source File: Operator.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Performs an operation without time control.
 *
 * @param action an action to execute.
 * @param param an action parameters.
 */
protected <R, P> void produceNoBlocking(NoBlockingAction<R, P> action, P param) {
    try {
        ActionProducer<R, P> noBlockingProducer = new ActionProducer<>(action, false);
        noBlockingProducer.setOutput(output.createErrorOutput());
        noBlockingProducer.setTimeouts(timeouts);
        noBlockingProducer.produceAction(param, null);
    } catch (InterruptedException e) {
        throw (new JemmyException("Exception during \""
                + action.getDescription()
                + "\" execution",
                e));
    }
    if (action.exception != null) {
        throw (new JemmyException("Exception during nonblocking \""
                + action.getDescription() + "\"",
                action.exception));
    }
}
 
Example #11
Source File: Action.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * performs action through shortcut
 *
 * @param nodes nodes to be action performed on
 * @throws UnsupportedOperationException when action does not support
 * shortcut mode
 */
public void performShortcut(Node[] nodes) {
    final KeyStroke[] strokes = getKeyStrokes();
    if (strokes == null) {
        throw new UnsupportedOperationException(getClass().toString() + " does not define shortcut");
    }
    testNodes(nodes);
    nodes[0].select();
    for (int i = 1; i < nodes.length; i++) {
        nodes[i].addSelectionPath();
    }
    try {
        Thread.sleep(SELECTION_WAIT_TIME);
    } catch (Exception e) {
        throw new JemmyException("Sleeping interrupted", e);
    }
    performShortcut();
}
 
Example #12
Source File: EditorOperatorTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Test of folding methods. */
public static void testFolding() {
    eo.waitFolding();
    assertFalse("Initial comment at line 2 should be expanded.", eo.isCollapsed(2));
    eo.setCaretPositionToLine(3);
    assertFalse("Initial comment at line 3 should be expanded.", eo.isCollapsed(3));
    try {
        eo.setCaretPosition("package sample1;", true); // NOI18N
        int line = eo.getLineNumber();
        eo.isCollapsed(line);
        fail("JemmyException should be thrown because no fold is at line " + line);
    } catch (JemmyException e) {
        // OK.
    }
    eo.setCaretPositionToLine(2);
    eo.collapseFold();
    assertTrue("Initial comment should be collapsed now.", eo.isCollapsed(2));
    eo.expandFold();
    eo.collapseFold(5);
    eo.expandFold(5);
}
 
Example #13
Source File: J2EETest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void runTest() throws Exception {
    if (testFileObj == null) {
        return;
    }

    String ext = testFileObj.getExt();
    if (JSP_EXTS.contains(ext)) {
        test(testFileObj, "<%--CC", "--%>");
    } else if (XML_EXTS.contains(ext)) {
        test(testFileObj, "<!--CC", "-->", false);
    } else if (JS_EXTS.contains(ext) || ext.equals("java")) {
        test(testFileObj, "/**CC", "*/", false);
    } else {
        throw new JemmyException("File extension of: " + testFileObj.getNameExt() + " is unsupported.");
    }
}
 
Example #14
Source File: ProgressSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Wait process with given name finished.
 */
public static void waitFinished(final String name, long timeout) {
    try {
        Waiter waiter = new Waiter(new Waitable() {
            public Object actionProduced(Object anObject) {
                return processInProgress(name) ? null : Boolean.TRUE;
            }
            public String getDescription() {
                return("Wait process "+name+" is finished.");
            }
        });
        waiter.getTimeouts().setTimeout("Waiter.WaitingTime", timeout);
        waiter.waitAction(null);
    } catch (InterruptedException e) {
        throw new JemmyException("Interrupted.", e);
    }
    
}
 
Example #15
Source File: ActionNoBlock.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * performs action through main menu
 *
 * @throws UnsupportedOperationException when action does not support menu
 * mode
 */
@Override
public void performMenu() {
    if (menuPath == null) {
        throw new UnsupportedOperationException(getClass().toString() + " does not define menu path");
    }
    // Need to wait here to be more reliable.
    // TBD - It can be removed after issue 23663 is solved.
    new EventTool().waitNoEvent(500);
    MainWindowOperator.getDefault().menuBar().pushMenuNoBlock(menuPath, "|");
    try {
        Thread.sleep(AFTER_ACTION_WAIT_TIME);
    } catch (Exception e) {
        throw new JemmyException("Sleeping interrupted", e);
    }
}
 
Example #16
Source File: Action.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * performs action through shortcut
 *
 * @throws UnsupportedOperationException if no shortcut is defined
 */
public void performShortcut() {
    KeyStroke[] strokes = getKeyStrokes();
    if (strokes == null) {
        throw new UnsupportedOperationException(getClass().toString() + " does not define shortcut");
    }
    for (int i = 0; i < strokes.length; i++) {
        new KeyRobotDriver(null).pushKey(null, strokes[i].getKeyCode(), strokes[i].getModifiers(), JemmyProperties.getCurrentTimeouts().create("ComponentOperator.PushKeyTimeout"));
        JemmyProperties.getProperties().getTimeouts().sleep("Action.WaitAfterShortcutTimeout");
    }
    try {
        Thread.sleep(AFTER_ACTION_WAIT_TIME);
    } catch (Exception e) {
        throw new JemmyException("Sleeping interrupted", e);
    }
}
 
Example #17
Source File: ActionNoBlock.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * performs action through shortcut
 *
 * @throws UnsupportedOperationException when action does not support
 * shortcut mode
 */
@Override
public void performShortcut() {
    final KeyStroke[] strokes = getKeyStrokes();
    if (strokes == null) {
        throw new UnsupportedOperationException(getClass().toString() + " does not define shortcut");
    }
    new Thread(new Runnable() {
        @Override
        public void run() {
            for (int i = 0; i < strokes.length; i++) {
                new KeyRobotDriver(null).pushKey(null, strokes[i].getKeyCode(), strokes[i].getModifiers(), JemmyProperties.getCurrentTimeouts().create("ComponentOperator.PushKeyTimeout"));
                JemmyProperties.getProperties().getTimeouts().sleep("Action.WaitAfterShortcutTimeout");
            }
        }
    }, "thread performing action through shortcut").start();
    try {
        Thread.sleep(AFTER_ACTION_WAIT_TIME);
    } catch (Exception e) {
        throw new JemmyException("Sleeping interrupted", e);
    }
}
 
Example #18
Source File: AttachWindowAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Uses Central.userDroppedTopComponents(ModeImpl mode, TopComponentDraggable draggable, String side)
 * to attach source TopComponent to target Mode according to sideConstant
 * value.
 * @param sourceTc source TopComponent
 * @param mode target mode
 * @param sideConstant side constant
 */
private static void attachTopComponent(TopComponent sourceTc, Mode mode, String sideConstant) {
    try {
        Class<?> centralClass = classForName("org.netbeans.core.windows.Central");
        Class<?> tcdClass = classForName("org.netbeans.core.windows.view.dnd.TopComponentDraggable");
        Class<?> modeImplClass = classForName("org.netbeans.core.windows.ModeImpl");
        Method attachMethod = centralClass.getMethod("userDroppedTopComponents", modeImplClass, tcdClass, String.class);
        Method getCentralMethod = WindowManager.getDefault().getClass().getDeclaredMethod("getCentral", (Class<?>[]) null);
        getCentralMethod.setAccessible(true);
        Object centralInstance = getCentralMethod.invoke(WindowManager.getDefault(), (Object[]) null);
        Constructor<?> tcdConstructor = tcdClass.getDeclaredConstructor(TopComponent.class);
        tcdConstructor.setAccessible(true);
        Object tcdInstance = tcdConstructor.newInstance(sourceTc);
        attachMethod.setAccessible(true);
        attachMethod.invoke(centralInstance, mode, tcdInstance, sideConstant);
    } catch (Exception e) {
        throw new JemmyException("Cannot attach TopComponent.", e);
    }
}
 
Example #19
Source File: MaximizeWindowAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Performs Maximize Window by IDE API on given top component operator 
 * which is activated before the action.
 * @param tco top component operator which should be activated and maximized
 */
public void performAPI(final TopComponentOperator tco) {
    tco.makeComponentVisible();
    // run in dispatch thread
    tco.getQueueTool().invokeSmoothly(new Runnable() {

        @Override
        public void run() {
            WindowManager wm = WindowManager.getDefault();
            TopComponent tc = (TopComponent) tco.getSource();
            Mode mode = wm.findMode(tc);
            if (mode == null) {
                throw new JemmyException("Mode not found for " + tc);
            }
            AttachWindowAction.callWindowManager("switchMaximizedMode", mode);
        }
    });
}
 
Example #20
Source File: SaveAllAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Waits until SaveAllAction is finished.
 */
private void waitFinished() {
    try {
        new Waiter(new Waitable() {
            @Override
            public Object actionProduced(Object systemAction) {
                return DataObject.getRegistry().getModifiedSet().isEmpty() ? Boolean.TRUE : null;
            }

            @Override
            public String getDescription() {
                return "SaveAllAction is finished";
            }
        }).waitAction(null);
    } catch (InterruptedException e) {
        throw new JemmyException("Waiting interrupted.", e);
    }
}
 
Example #21
Source File: JPopupMenuOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Waits popup defined by {@code popupChooser} parameter.
 *
 * @param popupChooser a component chooser specifying criteria for
 * JPopupMenu.
 * @return a JPopupMenu fitting the criteria.
 */
public static JPopupMenuOperator waitJPopupMenu(final ComponentChooser popupChooser) {
    try {
        WindowOperator wind = new WindowOperator(new WindowWaiter().waitWindow(new ComponentChooser() {
            @Override
            public boolean checkComponent(Component comp) {
                ComponentSearcher searcher = new ComponentSearcher((Container) comp);
                searcher.setOutput(JemmyProperties.getCurrentOutput().createErrorOutput());
                return searcher.findComponent(popupChooser) != null;
            }

            @Override
            public String getDescription() {
                return "Window containing \"" + popupChooser.getDescription() + "\" popup";
            }

            @Override
            public String toString() {
                return "JPopupMenuOperator.waitJPopupMenu.ComponentChooser{description = " + getDescription() + '}';
            }
        }));
        return new JPopupMenuOperator(wind);
    } catch (InterruptedException e) {
        throw (new JemmyException("Popup waiting has been interrupted", e));
    }
}
 
Example #22
Source File: Property.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Sets default value for this property. If default value is not available,
 * it does nothing.
 */
public void setDefaultValue() {
    try {
        property.restoreDefaultValue();
    } catch (Exception e) {
        throw new JemmyException("Exception while restoring default value.", e);
    }
    /*
    nameButtonOperator().clickForPopup();
    String menuItem = Bundle.getString("org.openide.explorer.propertysheet.Bundle",
    "SetDefaultValue");
    new JPopupMenuOperator().pushMenu(menuItem, "|");
    // need to wait until value button is changed
    new EventTool().waitNoEvent(100);
     */
}
 
Example #23
Source File: Property.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Returns property editor obtained by call PropUtils.getPropertyEditor().
 * It should be safe in any circumstancies (e.g. when IDE starts supporting 
 * XML-based editor registration).
 * @return PropertyEditor instance of this property.
 */
private PropertyEditor getPropertyEditor() {
    final AtomicReference<PropertyEditor> atomicReference = new AtomicReference<PropertyEditor>();
    new QueueTool().invokeSmoothly(new Runnable() {
        @Override
        public void run() {
            try {
                Class<?> clazz = Class.forName("org.openide.explorer.propertysheet.PropUtils");
                Method getPropertyEditorMethod = clazz.getDeclaredMethod("getPropertyEditor", new Class[]{Node.Property.class});
                getPropertyEditorMethod.setAccessible(true);
                atomicReference.set((PropertyEditor) getPropertyEditorMethod.invoke(null, new Object[]{property}));
            } catch (Exception e) {
                throw new JemmyException("PropUtils.getPropertyEditor() by reflection failed.", e);
            }
        }
    });
    return atomicReference.get();
}
 
Example #24
Source File: WidgetOperator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Waits for index-th widget specified by WidgetChooser under given parent
 * widget.
 *
 * @param parentWidget parent Widget
 * @param widgetChooser WidgetChooser implementation
 * @param index index to be found
 * @return Widget instance if found or throws JemmyException if not found.
 */
private static Widget waitWidget(final Widget parentWidget, final WidgetChooser widgetChooser, final int index) {
    try {
        Waiter waiter = new Waiter(new Waitable() {

            @Override
            public Object actionProduced(Object obj) {
                return findWidget(parentWidget, widgetChooser, index);
            }

            @Override
            public String getDescription() {
                return (index > 0 ? index + "-th " : "")
                        + (widgetChooser == null ? "Widget " : widgetChooser.getDescription())
                        + " displayed";
            }
        });
        Timeouts timeouts = JemmyProperties.getCurrentTimeouts().cloneThis();
        timeouts.setTimeout("Waiter.WaitingTime", timeouts.getTimeout("WidgetOperator.WaitWidgetTimeout"));
        waiter.setTimeouts(timeouts);
        waiter.setOutput(JemmyProperties.getCurrentOutput());
        return (Widget) waiter.waitAction(null);
    } catch (InterruptedException ex) {
        throw new JemmyException("Interrupted.", ex);
    }
}
 
Example #25
Source File: RobotDriver.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void doInitRobot() {
    try {
        ClassReference robotClassReverence = new ClassReference("java.awt.Robot");
        robotReference = new ClassReference(robotClassReverence.newInstance(null, null));
        robotReference.invokeMethod("setAutoDelay",
                new Object[]{(int) ((autoDelay != null)
                        ? autoDelay.getValue()
                        : 0)},
                new Class<?>[]{Integer.TYPE});
    } catch (InvocationTargetException
            | IllegalStateException
            | NoSuchMethodException
            | IllegalAccessException
            | ClassNotFoundException
            | InstantiationException e) {
        throw (new JemmyException("Exception during java.awt.Robot accessing", e));
    }
}
 
Example #26
Source File: ProgressOperator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Wait process with given name finished.
 */
public static void waitFinished(final String name, long timeout) {
    try {
        Waiter waiter = new Waiter(new Waitable() {
            public Object actionProduced(Object anObject) {
                return processInProgress(name) ? null : Boolean.TRUE;
            }
            public String getDescription() {
                return("Wait process "+name+" is finished.");
            }
        });
        waiter.getTimeouts().setTimeout("Waiter.WaitingTime", timeout);
        waiter.waitAction(null);
    } catch (InterruptedException e) {
        throw new JemmyException("Interrupted.", e);
    }
    
}
 
Example #27
Source File: NodeUtils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Test cut */
public static void testClipboard(final Object clipboard1) {        
    Waiter waiter = new Waiter(new Waitable() {
            public Object actionProduced(Object obj) {
                Object clipboard2 = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
                return clipboard1 != clipboard2 ? Boolean.TRUE : null;
            }
            public String getDescription() {
                return("Wait clipboard contains data"); // NOI18N
            }
    });
    try {
        waiter.waitAction(null);
    } catch (InterruptedException e) {
        throw new JemmyException("Waiting interrupted.", e);
    }
}
 
Example #28
Source File: TopComponentOperator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Saves content of this TopComponent. If it is not applicable or content
 * of TopComponent is not modified, it does nothing.
 */
public void save() {
    Savable savable = ((TopComponent) getSource()).getLookup().lookup(Savable.class);
    if (savable == null) {
        // try to find possible enclosing MultiviewTopComponent
        TopComponentOperator parentTco = findParentTopComponent();
        if (parentTco != null) {
            parentTco.save();
        }
    } else {
        try {
            savable.save();
        } catch (IOException e) {
            throw new JemmyException("Saving of TopComponent " + ((TopComponent) getSource()).getDisplayName() + " failed (Savable=" + savable + ").", e);  //NOI18N
        }
    }
}
 
Example #29
Source File: J2eeTestCase.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Returns J2eeServerNode for given server
 *
 * @param server
 * @return J2eeServerNode for given server
 */
protected J2eeServerNode getServerNode(Server server) {
    switch (server) {
        case GLASSFISH:
            return J2eeServerNode.invoke("GlassFish");
        case JBOSS:
            return J2eeServerNode.invoke("JBoss");
        case TOMCAT:
            return J2eeServerNode.invoke("Tomcat");
        case ANY:
            for (Server serv : Server.values()) {
                if (serv.equals(ANY)) {
                    continue;
                }
                try {
                    return getServerNode(serv);
                } catch (JemmyException e) {
                    // ignore and continue with next server
                }
            }
            throw new IllegalArgumentException("No server is registred in IDE");
        default:
            throw new IllegalArgumentException("Unsupported server");
    }
}
 
Example #30
Source File: MeasureEntityBeanActionTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize() {
    // open a java file in the editor
    beanNode = new Node(new ProjectsTabOperator().getProjectRootNode("TestApplication-ejb"), "Enterprise Beans|TestEntityEB");
    final ActionNoBlock action = new ActionNoBlock(null, popup_menu);
    try {
        new Waiter(new Waitable() {

            @Override
            public Object actionProduced(Object param) {
                return action.isEnabled(beanNode) ? Boolean.TRUE : null;
            }

            @Override
            public String getDescription() {
                return "wait menu is enabled";
            }
        }).waitAction(null);
    } catch (InterruptedException e) {
        throw new JemmyException("Interrupted.", e);
    }
    new OpenAction().performAPI(beanNode);
    editor = new EditorOperator("TestEntityBean.java");
}