mstover1    2002/07/17 20:44:21

  Modified:    src_1/org/apache/jmeter/config/gui ArgumentsPanel.java
               src_1/org/apache/jmeter/control/gui TestPlanGui.java
               src_1/org/apache/jmeter/functions CompoundFunction.java
               src_1/org/apache/jmeter/functions/gui FunctionHelper.java
               src_1/org/apache/jmeter/gui/tree JMeterTreeModel.java
               src_1/org/apache/jmeter/threads TestCompiler.java
  Log:
  Fixing problems with functions:
   - nested user-defined variables now allowed
   - user-defined variables loaded correctly
   - Functions as inner classes found
   - Functions only called once per sample-request
  
  Revision  Changes    Path
  1.9       +4 -3      
jakarta-jmeter/src_1/org/apache/jmeter/config/gui/ArgumentsPanel.java
  
  Index: ArgumentsPanel.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/config/gui/ArgumentsPanel.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ArgumentsPanel.java       16 Jul 2002 17:58:02 -0000      1.8
  +++ ArgumentsPanel.java       18 Jul 2002 03:44:21 -0000      1.9
  @@ -142,7 +142,7 @@
                super.configure(el);
                if(el instanceof Arguments)
                {
  -                     tableModel.args = (Arguments)el;
  +                     tableModel.setUnderlyingModel((Arguments)el.clone());
                }
                checkDeleteStatus();
        }
  @@ -348,6 +348,7 @@
                public void setUnderlyingModel(Arguments args)
                {
                        this.args = args;
  +                     this.fireTableDataChanged();
                }
   
                /****************************************
  
  
  
  1.6       +2 -1      
jakarta-jmeter/src_1/org/apache/jmeter/control/gui/TestPlanGui.java
  
  Index: TestPlanGui.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/control/gui/TestPlanGui.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TestPlanGui.java  16 Jul 2002 17:58:02 -0000      1.5
  +++ TestPlanGui.java  18 Jul 2002 03:44:21 -0000      1.6
  @@ -107,6 +107,7 @@
        {
                super.configure(el);
                
functionalMode.setSelected(((AbstractTestElement)el).getPropertyAsBoolean(TestPlan.FUNCTIONAL_MODE));
  +             
argsPanel.configure((Arguments)el.getProperty(TestPlan.USER_DEFINED_VARIABLES));
        }
        
        /****************************************
  
  
  
  1.2       +53 -2     
jakarta-jmeter/src_1/org/apache/jmeter/functions/CompoundFunction.java
  
  Index: CompoundFunction.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/functions/CompoundFunction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CompoundFunction.java     17 Jul 2002 01:27:46 -0000      1.1
  +++ CompoundFunction.java     18 Jul 2002 03:44:21 -0000      1.2
  @@ -39,7 +39,7 @@
        {
                try
                {
  -                     List classes = ClassFinder.findClassesThatExtend(new 
Class[]{Function.class});
  +                     List classes = ClassFinder.findClassesThatExtend(new 
Class[]{Function.class},true);
                        Iterator iter = classes.iterator();
                        while(iter.hasNext())
                        {
  @@ -174,6 +174,31 @@
                if(!hasFunction)
                {
                        staticSubstitution = compiledComponents.getLast().toString();
  +                     if(hasStatics())
  +                     {
  +                             compiledComponents.clear();
  +                             setParameters(staticSubstitution);
  +                     }
  +             }
  +             else if(hasStatics())
  +             {
  +                     iter = new LinkedList(compiledComponents).iterator();
  +                     while(iter.hasNext())
  +                     {
  +                             Object item = iter.next();
  +                             if(item instanceof StringBuffer)
  +                             {
  +                                     CompoundFunction nestedFunc = new 
CompoundFunction();
  +                                     nestedFunc.setUserDefinedVariables(new 
HashMap());
  +                                     nestedFunc.setParameters(item.toString());
  +                                     if(nestedFunc.hasFunction())
  +                                     {
  +                                             int index = 
compiledComponents.indexOf(item);
  +                                             compiledComponents.remove(index);
  +                                             
compiledComponents.add(index,nestedFunc);
  +                                     }
  +                             }
  +                     } 
                }
        }
   
  @@ -260,8 +285,10 @@
                
                public void setUp()
                {
  +                     Map userDefinedVariables = new HashMap();
  +                     userDefinedVariables.put("my_regex",".*");
                        function = new CompoundFunction();
  -                     function.setUserDefinedVariables(new HashMap());
  +                     function.setUserDefinedVariables(userDefinedVariables);
                        result = new SampleResult();
                        result.setResponseData("<html>hello world</html>".getBytes());
                }
  @@ -321,6 +348,30 @@
                        assertEquals(0,function.compiledComponents.size());
                        assertTrue(!function.hasFunction());
                        assertTrue(!function.hasStatics());
  +             }
  +             
  +             public void testNestedExample1() throws Exception
  +             {
  +                     
function.setParameters("${__regexFunction(<html>(${my_regex})</html>,$1$)}${__regexFunction(<html>(.*o)(.*o)(.*)</html>,$1$$3$)}");
  +                     assertEquals(2,function.compiledComponents.size());
  +                     assertTrue(function.hasFunction());
  +                     assertTrue(function.hasStatics());
  +                     assertEquals("hello 
world",((Function)function.compiledComponents.get(0)).execute(result,null));
  +                     
assertEquals("hellorld",((Function)function.compiledComponents.get(1)).execute(result,null));
  +                     assertEquals("hello 
worldhellorld",function.execute(result,null));
  +                     
assertEquals("<html>(.*)</html>,$1$<html>(.*o)(.*o)(.*)</html>,$1$$3$",
  +                                     function.execute(null,null));
  +             }
  +             
  +             public void testNestedExample2() throws Exception
  +             {
  +                     
function.setParameters("${__regexFunction(<html>(${my_regex})</html>,$1$)}");
  +                     assertEquals(1,function.compiledComponents.size());
  +                     assertTrue(function.compiledComponents.getFirst() instanceof 
RegexFunction);
  +                     assertTrue(function.hasFunction());
  +                     assertTrue(function.hasStatics());
  +                     assertEquals("hello 
world",((Function)function.compiledComponents.getFirst()).execute(result,null));
  +                     assertEquals("hello world",function.execute(result,null));
                }
        }
   
  
  
  
  1.2       +1 -1      
jakarta-jmeter/src_1/org/apache/jmeter/functions/gui/FunctionHelper.java
  
  Index: FunctionHelper.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/functions/gui/FunctionHelper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FunctionHelper.java       17 Jul 2002 01:27:46 -0000      1.1
  +++ FunctionHelper.java       18 Jul 2002 03:44:21 -0000      1.2
  @@ -74,7 +74,7 @@
        {
                try {
                        List functionClasses = ClassFinder.findClassesThatExtend(
  -                                     new Class[]{Function.class});
  +                                     new Class[]{Function.class},true);
                        Iterator iter = functionClasses.iterator();
                        String[] functionNames = new String[functionClasses.size()];
                        int count = 0;
  
  
  
  1.7       +2 -1      
jakarta-jmeter/src_1/org/apache/jmeter/gui/tree/JMeterTreeModel.java
  
  Index: JMeterTreeModel.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/gui/tree/JMeterTreeModel.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JMeterTreeModel.java      7 Jun 2002 02:00:35 -0000       1.6
  +++ JMeterTreeModel.java      18 Jul 2002 03:44:21 -0000      1.7
  @@ -123,6 +123,7 @@
                        if(item instanceof TestPlanGui)
                        {
                                current = 
(JMeterTreeNode)((JMeterTreeNode)getRoot()).getChildAt(0);
  +                             current.configure(item.createTestElement());
                                addSubTree(subTree.get(item), current);
                        }
                        else
  
  
  
  1.8       +9 -6      jakarta-jmeter/src_1/org/apache/jmeter/threads/TestCompiler.java
  
  Index: TestCompiler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src_1/org/apache/jmeter/threads/TestCompiler.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TestCompiler.java 17 Jul 2002 01:27:46 -0000      1.7
  +++ TestCompiler.java 18 Jul 2002 03:44:21 -0000      1.8
  @@ -176,7 +176,10 @@
                                {
                                        objectsWithFunctions.add(item);
                                }
  -                             configs.add(item);
  +                             if(item != sam)
  +                             {
  +                                     configs.add(item);
  +                             }
                        }
                }
                if(hasFunctions(sam))
  
  
  

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

Reply via email to