mstover1    2003/04/01 07:24:37

  Modified:    src/components/org/apache/jmeter/assertions
                        SizeAssertion.java
               src/components/org/apache/jmeter/assertions/gui
                        SizeAssertionGui.java
  Log:
  Size assertion provides equal, not equal, greater than, less than options (Elan 
Chezhiyan)
  
  Revision  Changes    Path
  1.5       +21 -2     
jakarta-jmeter/src/components/org/apache/jmeter/assertions/SizeAssertion.java
  
  Index: SizeAssertion.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/assertions/SizeAssertion.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SizeAssertion.java        5 Feb 2003 05:12:02 -0000       1.4
  +++ SizeAssertion.java        1 Apr 2003 15:24:37 -0000       1.5
  @@ -86,6 +86,7 @@
        public final static int LESSTHANEQUAL = 6;
        /** Key for storing assertion-informations in the jmx-file. */
        private static final String SIZE_KEY = "SizeAssertion.size";
  +        private static final String OPERATOR_KEY="SizeAssertion.operator";
        byte[] resultData;
        
        /**
  @@ -118,6 +119,23 @@
                return getPropertyAsLong(SIZE_KEY);
        }
   
  +        /******
  +         * set the Operator 
  +         ******/
  +        public void setCompOper(int operator) {
  +               setProperty(OPERATOR_KEY,new Integer(operator));
  +
  +        }
  +
  +     /**
  +      * Returns the operator to be asserted. EQUAL = 1, NOTEQUAL = 2
  +         * GREATERTHAN = 3,LESSTHAN = 4,GREATERTHANEQUAL = 5,LESSTHANEQUAL = 6
  +      */
  +        
  +        public int getCompOper() {
  +               return getPropertyAsInt(OPERATOR_KEY);
  +        }
  +
        /**
         * Set the size that shall be asserted.
         *
  @@ -198,7 +216,8 @@
        
        private boolean compareSize(long resultSize) {
                boolean result = false;
  -             switch (comparator) 
  +            int comp =getCompOper();
  +             switch (comp) 
                {
                        case EQUAL: 
                                result = (resultSize == getAllowedSize());
  
  
  
  1.6       +45 -9     
jakarta-jmeter/src/components/org/apache/jmeter/assertions/gui/SizeAssertionGui.java
  
  Index: SizeAssertionGui.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/assertions/gui/SizeAssertionGui.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SizeAssertionGui.java     28 Feb 2003 14:21:44 -0000      1.5
  +++ SizeAssertionGui.java     1 Apr 2003 15:24:37 -0000       1.6
  @@ -96,7 +96,8 @@
   
        private JTextField size;
        SizeAssertion sa = new SizeAssertion();
  -
  +        JRadioButton 
equalButton,notequalButton,greaterthanButton,lessthanButton,greaterthanequalButton,lessthanequalButton;
  +        private int execState; //store the operator 
        /****************************************
         * !ToDo (Constructor description)
         ***************************************/
  @@ -142,6 +143,7 @@
                assertionSize = Long.MAX_VALUE;
           }
           ((SizeAssertion)el).setAllowedSize(assertionSize);
  +        ((SizeAssertion)el).setCompOper(getState());
       }
   
        /****************************************
  @@ -152,8 +154,41 @@
                super.configure(el);
                SizeAssertion assertion = (SizeAssertion)el;
                size.setText(String.valueOf(assertion.getAllowedSize()));
  +                setState(assertion.getCompOper());  
        }
   
  +        /***************************************
  +         * setting the state of the radio Button
  +         ***************************************/
  +        public void setState(int state){
  +            if (state ==1){
  +                equalButton.setSelected(true);
  +                execState=1;
  +            }else if (state==2){
  +                notequalButton.setSelected(true);
  +                execState=2;
  +            }else if(state==3){
  +                greaterthanButton.setSelected(true);
  +                execState=3;
  +            }else if(state==4){
  +                lessthanButton.setSelected(true);
  +                execState=4;
  +            }else if(state==5){
  +                greaterthanequalButton.setSelected(true);
  +                execState=5;
  +            }else if(state==6){
  +                lessthanequalButton.setSelected(true);
  +                execState=6;
  +            }
  +        }
  +
  +        /**********************************
  +         * getting the state of the radio Button
  +         **********************************/
  +     public int getState()
  +     {
  +            return execState;
  +     }
        private void init()
        {
                this.setLayout(new VerticalLayout(5, VerticalLayout.LEFT, 
VerticalLayout.TOP));
  @@ -188,33 +223,33 @@
                
                ButtonGroup comparatorButtonGroup = new ButtonGroup();
                
  -             JRadioButton equalButton = new JRadioButton("=");
  +             equalButton = new JRadioButton("=");
                equalButton.setSelected(true);
                equalButton.setActionCommand(new 
Integer(SizeAssertion.EQUAL).toString());
                equalButton.addActionListener(this);
                comparatorButtonGroup.add(equalButton);
                                
  -             JRadioButton notequalButton = new JRadioButton("!=");
  +             notequalButton = new JRadioButton("!=");
                notequalButton.setActionCommand(new 
Integer(SizeAssertion.NOTEQUAL).toString());
                notequalButton.addActionListener(this);
                comparatorButtonGroup.add(notequalButton);
                
  -             JRadioButton greaterthanButton = new JRadioButton(">");
  +             greaterthanButton = new JRadioButton(">");
                greaterthanButton.setActionCommand(new 
Integer(SizeAssertion.GREATERTHAN).toString());
                greaterthanButton.addActionListener(this);
                comparatorButtonGroup.add(greaterthanButton);
                
  -             JRadioButton lessthanButton = new JRadioButton("<");
  +             lessthanButton = new JRadioButton("<");
                lessthanButton.setActionCommand(new 
Integer(SizeAssertion.LESSTHAN).toString());
                lessthanButton.addActionListener(this);
                comparatorButtonGroup.add(lessthanButton);
                
  -             JRadioButton greaterthanequalButton = new JRadioButton(">=");
  +             greaterthanequalButton = new JRadioButton(">=");
                greaterthanequalButton.setActionCommand(new 
Integer(SizeAssertion.GREATERTHANEQUAL).toString());
                greaterthanequalButton.addActionListener(this);
                comparatorButtonGroup.add(greaterthanequalButton);
                
  -             JRadioButton lessthanequalButton = new JRadioButton("<=");
  +             lessthanequalButton = new JRadioButton("<=");
                lessthanequalButton.setActionCommand(new 
Integer(SizeAssertion.LESSTHANEQUAL).toString());
                lessthanequalButton.addActionListener(this);
                comparatorButtonGroup.add(lessthanequalButton);
  @@ -278,7 +313,8 @@
         ***************************************/
        public void actionPerformed(ActionEvent e) {
                int comparator = new Integer(e.getActionCommand()).intValue(); 
  -     sa.setLogicalComparator(comparator);
  +                         execState=comparator;
  +            // sa.setLogicalComparator(comparator);
       }
       
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to