Package org.jemmy

Examples of org.jemmy.JemmyException


     * @param rect Part of the control to capture
     * @return TODO find a replacement
     */
    public Image getScreenImage(Rectangle rect) {
        if (getEnvironment().getImageCapturer() == null) {
            throw new JemmyException("Image capturer is not specified.");
        }
        return getEnvironment().getImageCapturer().capture(this, rect);
    }
View Full Code Here


                    return m.invoke(this, !type.equals(Void.class) ? type : Object.class);
                } else {
                    throw new InterfaceException(this, interfaceClass);
                }
            } catch (IllegalAccessException ex) {
                throw new JemmyException("Unable to call method \"" + m.getName() + "()\"", ex, this);
            } catch (IllegalArgumentException ex) {
                throw new JemmyException("Unable to call method \"" + m.getName() + "()\"", ex, this);
            } catch (InvocationTargetException ex) {
                throw new JemmyException("Unable to call method \"" + m.getName() + "()\"", ex, this);
            }
        }
        return null;
    }
View Full Code Here

                        value = getFieldProperty(s);
                    } catch (Exception e) {
                        getEnvironment().getOutput().printStackTrace(e);
                        value = e.toString();
                        if (!(e instanceof JemmyException) && !quiet) {
                            throw new JemmyException("Exception while getting property \"" + s + "\"", e);
                        }
                    }
                    properties.put(s, value);
                }
            }
            if (cls.isAnnotationPresent(MethodProperties.class)) {
                for (String s : cls.getAnnotation(MethodProperties.class).value()) {
                    Object value;
                    try {
                        value = getMethodProperty(s);
                    } catch (Exception e) {
                        getEnvironment().getOutput().printStackTrace(e);
                        value = e.toString();
                        if (!(e instanceof JemmyException) && !quiet) {
                            throw new JemmyException("Exception while getting property \"" + s + "\"", e);
                        }
                    }
                    properties.put(s, value);
                }
            }
View Full Code Here

                    } catch (Exception e) {
                        if (quiet) {
                            getEnvironment().getOutput().printStackTrace(e);
                            value = e.toString();
                        } else {
                            throw new JemmyException("Exception while getting property \"" + name + "\"", e);
                        }
                    }
                    properties.put(name, value);
                }
            }
View Full Code Here

        }
    }

    private void checkPropertyMethod(Method m) {
        if (m.getParameterTypes().length > 0) {
            throw new JemmyException("Method marked by @Property must not have parameters: "
                    + m.getDeclaringClass().getName() + "." + m.getName());
        }
    }
View Full Code Here

    private Object getProperty(Object object, Method m) {
        Property prop = m.getAnnotation(Property.class);
        try {
            return m.invoke(object);
        } catch (IllegalAccessException ex) {
            throw new JemmyException("Unable to obtain property \"" + prop.value() + "\"", ex, this);
        } catch (IllegalArgumentException ex) {
            throw new JemmyException("Unable to obtain property \"" + prop.value() + "\"", ex, this);
        } catch (InvocationTargetException ex) {
            throw new JemmyException("Unable to obtain property \"" + prop.value() + "\"", ex, this);
        }
    }
View Full Code Here

            return getMethodProperty(name);
        }
        if (hasFieldProperty(name)) {
            return getFieldProperty(name);
        }
        throw new JemmyException("No property \"" + name + "\"", this);
    }
View Full Code Here

    private Object getInterfaceProperty(Class cls, Object instance, String name) {
        Method m = getPropertyMethod(cls, name);
        if (m != null) {
            return getProperty(instance, m);
        }
        throw new JemmyException("No property \"" + name + "\" in interface " + cls.getName(), instance);
    }
View Full Code Here

     * @param name
     * @return
     */
    public Object getFieldProperty(final String name) {
        if (!hasFieldProperty(name)) {
            throw new JemmyException("No \"" + name + "\" field property specified on " + getClass().getName());
        }
        GetAction action = new GetAction() {

            @Override
            public void run(Object... parameters) throws Exception {
                setResult(getControl().getClass().getField(name).get(getControl()));
            }
        };
        Object result = action.dispatch(env);
        if (action.getThrowable() != null) {
            throw new JemmyException("Unable to obtain property \"" + name + "\"", action.getThrowable(), this);
        }
        return result;
    }
View Full Code Here

     * @param name
     * @return
     */
    public Object getMethodProperty(final String name) {
        if (!hasMethodProperty(name)) {
            throw new JemmyException("No \"" + name + "\" method property specified on " + getClass().getName());
        }
        GetAction action = new GetAction() {

            @Override
            public void run(Object... parameters) throws Exception {
                setResult(getControl().getClass().getMethod(name).invoke(getControl()));
            }

            @Override
            public String toString() {
                return "Getting property \"" + name + "\" on " + getClass().getName();
            }
        };
        Object result = action.dispatch(env);
        if (action.getThrowable() != null) {
            throw new JemmyException("Unable to obtain property \"" + name + "\"", action.getThrowable(), this);
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of org.jemmy.JemmyException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.