Class PropChooser

  • All Implemented Interfaces:
    ComponentChooser, Outputable
    Direct Known Subclasses:
    StringPropChooser

    public class PropChooser
    extends java.lang.Object
    implements ComponentChooser, Outputable
    Implementation of org.netbeans.jemmy.ComponentChooser interface. Class can be used to find component by its field/methods values.
    Example:
                String[] methods = {"getClientProperty"};
                Object[][] params = {{"classname"}};
                Class[][] classes = {{Object.class}};
                Object[] results = {"javax.swing.JCheckBox"};
     
                JCheckBox box = JCheckBoxOperator.findJCheckBox(frm0, new PropChooser(methods, params, classes, results));
     
    Or:
                String[] methods = {"getText"};
                Object[] results = {"Open"};
     
                JButtonOperator box = new JButtonOperator(containerOperator, new PropChooser(fields, results));
     
    Author:
    Alexandre Iline (alexandre.iline@sun.com)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.Class[][] classes
      Classes of parameters.
      protected java.lang.Object[][] params
      Methods parameters.
      protected java.lang.String[] propNames
      Names of methods to check.
      protected java.lang.Object[] results
      Expected results of methods.
    • Constructor Summary

      Constructors 
      Constructor Description
      PropChooser​(java.lang.String[] propNames, java.lang.Object[] results)
      Constructs a PropChooser object for checking of methods with no parameters.
      PropChooser​(java.lang.String[] propNames, java.lang.Object[][] params, java.lang.Class[][] classes, java.lang.Object[] results)
      Constructs a PropChooser object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean checkComponent​(java.awt.Component comp)
      Check if the component argument meets the search criteria.
      protected boolean checkProperty​(java.lang.Object value, java.lang.Object etalon)
      Method to check one method result with an etalon.
      java.lang.String getDescription()
      Returns searched component description.
      TestOut getOutput()
      Returns print output streams or writers.
      void setOutput​(TestOut output)
      Defines print output streams or writers.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • propNames

        protected java.lang.String[] propNames
        Names of methods to check.
      • params

        protected java.lang.Object[][] params
        Methods parameters.
      • classes

        protected java.lang.Class[][] classes
        Classes of parameters.
      • results

        protected java.lang.Object[] results
        Expected results of methods.
    • Constructor Detail

      • PropChooser

        public PropChooser​(java.lang.String[] propNames,
                           java.lang.Object[][] params,
                           java.lang.Class[][] classes,
                           java.lang.Object[] results)
        Constructs a PropChooser object.
        Parameters:
        propNames - Names of methods/fields
        params - Parameters values for methods.
        params[0] is an array of parameters for propNames[0] methods.
        If propNames[0] is a field, params[0] is ignored.
        classes - Parameters classes.
        results - Objects to compare method/field values to.
        A value of propNames[0] method/field should be equal to results[0] object.
      • PropChooser

        public PropChooser​(java.lang.String[] propNames,
                           java.lang.Object[] results)
        Constructs a PropChooser object for checking of methods with no parameters.
        Parameters:
        propNames - Names of methods/fields
        results - Objects to compare method/field values to.
    • Method Detail

      • setOutput

        public void setOutput​(TestOut output)
        Description copied from interface: Outputable
        Defines print output streams or writers.
        Specified by:
        setOutput in interface Outputable
        Parameters:
        output - Identify the streams or writers used for print output.
        See Also:
        Outputable.getOutput()
      • checkComponent

        public boolean checkComponent​(java.awt.Component comp)
        Description copied from interface: ComponentChooser
        Check if the component argument meets the search criteria.
        Specified by:
        checkComponent in interface ComponentChooser
        Parameters:
        comp - Component to check.
        Returns:
        true when the component conforms to the search criteria; false otherwise.
      • getDescription

        public java.lang.String getDescription()
        Description copied from interface: ComponentChooser
        Returns searched component description.
        Specified by:
        getDescription in interface ComponentChooser
        Returns:
        a String representing the description value
      • checkProperty

        protected boolean checkProperty​(java.lang.Object value,
                                        java.lang.Object etalon)
        Method to check one method result with an etalon. Can be overrided by a subclass.
        Parameters:
        value - Method/field value
        etalon - Object to compare to.
        Returns:
        true if the value matches the etalon.