jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1197425 - in /jmeter/trunk/src: components/org/apache/jmeter/config/ components/org/apache/jmeter/extractor/ core/org/apache/jmeter/gui/ core/org/apache/jmeter/gui/action/ core/org/apache/jmeter/resources/ core/org/apache/jmeter/testelemen...
Date Fri, 04 Nov 2011 08:34:08 GMT
Author: pmouawad
Date: Fri Nov  4 08:34:07 2011
New Revision: 1197425

URL: http://svn.apache.org/viewvc?rev=1197425&view=rev
Log:
Bug 51876 - Functionnality to search in Samplers TreeView
Changed implementation to:
- Add ability to search with regexp 
- Add ability to search in case sensitive and insentive modes
- Plug additional search implementations

Added:
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/RawTextSearcher.java   (with props)
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/RegexpSearcher.java   (with props)
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/SearchTreeDialog.java   (with props)
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/Searcher.java   (with props)
Modified:
    jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSet.java
    jmeter/trunk/src/components/org/apache/jmeter/extractor/RegexExtractor.java
    jmeter/trunk/src/components/org/apache/jmeter/extractor/XPathExtractor.java
    jmeter/trunk/src/core/org/apache/jmeter/gui/Searchable.java
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/SearchTreeCommand.java
    jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
    jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractScopedTestElement.java
    jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractTestElement.java
    jmeter/trunk/src/core/org/apache/jmeter/util/BeanShellTestElement.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java

Modified: jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSet.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSet.java?rev=1197425&r1=1197424&r2=1197425&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSet.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/config/CSVDataSet.java Fri Nov  4 08:34:07
2011
@@ -19,8 +19,8 @@
 package org.apache.jmeter.config;
 
 import java.io.IOException;
+import java.util.List;
 
-import org.apache.jmeter.config.ConfigTestElement;
 import org.apache.jmeter.engine.event.LoopIterationEvent;
 import org.apache.jmeter.engine.event.LoopIterationListener;
 import org.apache.jmeter.save.CSVSaveService;
@@ -255,19 +255,14 @@ public class CSVDataSet extends ConfigTe
     public void setShareMode(String value) {
         this.shareMode = value;
     }
-
+    
     /** 
      * {@inheritDoc}}
      */
     @Override
-    public boolean searchContent(String textToSearch) throws Exception {
-        if(super.searchContent(textToSearch)) {
-            return true;
-        }
-        String searchedTextLowerCase = textToSearch.toLowerCase();
-        if(testField(getPropertyAsString("variableNames"), searchedTextLowerCase)) {
-            return true;
-        }
-        return false;
+    public List<String> getSearchableTokens() throws Exception {
+        List<String> result = super.getSearchableTokens();
+        result.add(getPropertyAsString("variableNames"));
+        return result;
     }
 }

Modified: jmeter/trunk/src/components/org/apache/jmeter/extractor/RegexExtractor.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/extractor/RegexExtractor.java?rev=1197425&r1=1197424&r2=1197425&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/extractor/RegexExtractor.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/extractor/RegexExtractor.java Fri Nov  4
08:34:07 2011
@@ -453,25 +453,16 @@ public class RegexExtractor extends Abst
     public void setUseField(String actionCommand) {
         setProperty(MATCH_AGAINST,actionCommand);
     }
-
-    /**
-     * {@inheritDoc}
+    
+    /** 
+     * {@inheritDoc}}
      */
     @Override
-    public boolean searchContent(String textToSearch) throws Exception {
-        if(super.searchContent(textToSearch)) {
-            return true;
-        }
-        String searchedTextLowerCase = textToSearch.toLowerCase();
-        if(testField(getRefName(), searchedTextLowerCase)) {
-            return true;
-        }
-        if(testField(getDefaultValue(), searchedTextLowerCase)) {
-            return true;
-        }
-        if(testField(getRegex(), searchedTextLowerCase)) {
-            return true;
-        }
-        return false;
+    public List<String> getSearchableTokens() throws Exception {
+        List<String> result = super.getSearchableTokens();
+        result.add(getRefName());
+        result.add(getDefaultValue());
+        result.add(getRegex());
+        return result;
     }
 }

Modified: jmeter/trunk/src/components/org/apache/jmeter/extractor/XPathExtractor.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/extractor/XPathExtractor.java?rev=1197425&r1=1197424&r2=1197425&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/extractor/XPathExtractor.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/extractor/XPathExtractor.java Fri Nov  4
08:34:07 2011
@@ -387,25 +387,16 @@ public class XPathExtractor extends Abst
         }
         return sw.toString();
     }
-
-    /**
-     * {@inheritDoc}
+    
+    /** 
+     * {@inheritDoc}}
      */
     @Override
-    public boolean searchContent(String textToSearch) throws Exception {
-        if(super.searchContent(textToSearch)) {
-            return true;
-        }
-        String searchedTextLowerCase = textToSearch.toLowerCase();
-        if(testField(getRefName(), searchedTextLowerCase)) {
-            return true;
-        }
-        if(testField(getDefaultValue(), searchedTextLowerCase)) {
-            return true;
-        }
-        if(testField(getXPathQuery(), searchedTextLowerCase)) {
-            return true;
-        }
-        return false;
+    public List<String> getSearchableTokens() throws Exception {
+        List<String> result = super.getSearchableTokens();
+        result.add(getRefName());
+        result.add(getDefaultValue());
+        result.add(getXPathQuery());
+        return result;
     }
 }

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/Searchable.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/Searchable.java?rev=1197425&r1=1197424&r2=1197425&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/Searchable.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/Searchable.java Fri Nov  4 08:34:07 2011
@@ -18,17 +18,16 @@
 
 package org.apache.jmeter.gui;
 
+import java.util.List;
+
 /**
  * Interface for nodes that are searchable
  */
 public interface Searchable {
-
     /**
-     * 
-     * @param textToSearch
-     * @return true if search was successful
+     * @return List<String> of searchable tokens
+     * @throws Exception
      */
-    boolean searchContent(String textToSearch)
-        throws Exception ;
-
+    List<String> getSearchableTokens() 
+    	throws Exception;
 }

Added: jmeter/trunk/src/core/org/apache/jmeter/gui/action/RawTextSearcher.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/RawTextSearcher.java?rev=1197425&view=auto
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/RawTextSearcher.java (added)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/RawTextSearcher.java Fri Nov  4 08:34:07
2011
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.gui.action;
+
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * 
+ */
+public class RawTextSearcher implements Searcher {
+	private boolean caseSensitive;
+	private String textToSearch;
+	
+
+	/**
+	 * 
+	 * @param caseSensitive
+	 * @param textToSearch
+	 */
+	public RawTextSearcher(boolean caseSensitive, String textToSearch) {
+		super();
+		this.caseSensitive = caseSensitive;
+		if(caseSensitive) {
+			this.textToSearch = textToSearch;
+		} else {
+			this.textToSearch = textToSearch.toLowerCase();
+		}
+	}
+
+
+
+	/* (non-Javadoc)
+	 * @see org.apache.jmeter.gui.action.ISearcher#search(java.util.List)
+	 */
+	@Override
+	public boolean search(List<String> textTokens) {
+		boolean result = false;
+		for (String searchableToken : textTokens) {
+			if(!StringUtils.isEmpty(searchableToken)) {
+				if(caseSensitive) {
+					result = searchableToken.indexOf(textToSearch)>=0;
+				} else {
+					result = searchableToken.toLowerCase().indexOf(textToSearch)>=0;
+				}
+				if (result) {
+					return result;
+				}
+			}
+		}
+		return false;
+	}
+
+	/**
+     * Returns true if searchedTextLowerCase is in value
+     * @param value
+     * @param searchedTextLowerCase
+     * @return true if searchedTextLowerCase is in value
+     */
+    protected boolean testField(String value, String searchedTextLowerCase) {
+        if(!StringUtils.isEmpty(value)) {
+            return value.toLowerCase().indexOf(searchedTextLowerCase)>=0;
+        }
+        return false;
+    }
+}
\ No newline at end of file

Propchange: jmeter/trunk/src/core/org/apache/jmeter/gui/action/RawTextSearcher.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jmeter/trunk/src/core/org/apache/jmeter/gui/action/RegexpSearcher.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/RegexpSearcher.java?rev=1197425&view=auto
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/RegexpSearcher.java (added)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/RegexpSearcher.java Fri Nov  4 08:34:07
2011
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.gui.action;
+
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * Regexp search implementation
+ */
+public class RegexpSearcher implements Searcher {
+	private boolean caseSensitive;
+	private Pattern pattern;
+	
+
+	/**
+	 * @param caseSensitive
+	 * @param regexp
+	 */
+	public RegexpSearcher(boolean caseSensitive, String regexp) {
+		super();
+		this.caseSensitive = caseSensitive;
+		String newRegexp = ".*"+regexp+".*";
+		if(caseSensitive) {
+			pattern = Pattern.compile(newRegexp);
+		} else {
+			pattern = Pattern.compile(newRegexp.toLowerCase());
+		}
+	}
+
+
+	/* (non-Javadoc)
+	 * @see org.apache.jmeter.gui.action.ISearcher#search(java.util.List)
+	 */
+	@Override
+	public boolean search(List<String> textTokens) {
+		for (String searchableToken : textTokens) {
+			if(!StringUtils.isEmpty(searchableToken)) {
+				Matcher matcher = null; 
+				if(caseSensitive) {
+					matcher = pattern.matcher(searchableToken);
+				} else {
+					matcher = pattern.matcher(searchableToken.toLowerCase());
+				}
+				if(matcher.find()) {
+					return true;
+				}
+			}
+		}
+		return false;
+	}
+}
\ No newline at end of file

Propchange: jmeter/trunk/src/core/org/apache/jmeter/gui/action/RegexpSearcher.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/SearchTreeCommand.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/SearchTreeCommand.java?rev=1197425&r1=1197424&r2=1197425&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/SearchTreeCommand.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/SearchTreeCommand.java Fri Nov  4 08:34:07
2011
@@ -20,27 +20,13 @@ package org.apache.jmeter.gui.action;
 
 import java.awt.event.ActionEvent;
 import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
 import java.util.Set;
 
-import javax.swing.JOptionPane;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.jmeter.gui.GuiPackage;
-import org.apache.jmeter.gui.Searchable;
-import org.apache.jmeter.gui.tree.JMeterTreeModel;
-import org.apache.jmeter.gui.tree.JMeterTreeNode;
-import org.apache.jmeter.util.JMeterUtils;
-import org.apache.jorphan.logging.LoggingManager;
-import org.apache.log.Logger;
-
 /**
  * Search nodes for a text
  * TODO Enhance search dialog to select kind of nodes ....
  */
 public class SearchTreeCommand extends AbstractAction {
-    private Logger logger = LoggingManager.getLoggerForClass();
 
     private static final Set<String> commands = new HashSet<String>();
 
@@ -53,39 +39,7 @@ public class SearchTreeCommand extends A
      */
     @Override
     public void doAction(ActionEvent e) {
-        String wordToSearch = JOptionPane.showInputDialog(
-                GuiPackage.getInstance().getMainFrame(),
-                JMeterUtils.getResString("search_word"),  // $NON-NLS-1$
-                JMeterUtils.getResString("search_tree_title"),  // $NON-NLS-1$
-                JOptionPane.QUESTION_MESSAGE);
-        if(wordToSearch==null) {
-            return;
-        }
-        ActionRouter.getInstance().doActionNow(new ActionEvent(e.getSource(), e.getID(),
ActionNames.SEARCH_RESET));
-        GuiPackage guiPackage = GuiPackage.getInstance();
-        JMeterTreeModel jMeterTreeModel = guiPackage.getTreeModel();
-        Set<JMeterTreeNode> nodes = new HashSet<JMeterTreeNode>();
-        for (JMeterTreeNode jMeterTreeNode : jMeterTreeModel.getNodesOfType(Searchable.class))
{
-            try {
-                if (jMeterTreeNode.getUserObject() instanceof Searchable){
-                    Searchable searchable = (Searchable) jMeterTreeNode.getUserObject();
-                    List<JMeterTreeNode> matchingNodes = jMeterTreeNode.getPathToThreadGroup();
-                    if(!StringUtils.isEmpty(wordToSearch)) {
-                        boolean result = searchable.searchContent(wordToSearch);
-                        if(result) {
-                            nodes.addAll(matchingNodes);
-                        }
-                    }
-                }
-            } catch (Exception ex) {
-                logger.error("Error occured searching for word:"+ wordToSearch, ex);
-            }
-        }
-        for (Iterator<JMeterTreeNode> iterator = nodes.iterator(); iterator.hasNext();)
{
-            JMeterTreeNode jMeterTreeNode = iterator.next();
-            jMeterTreeNode.setMarkedBySearch(true);
-        }
-        GuiPackage.getInstance().getMainFrame().repaint();
+    	new SearchTreeDialog().setVisible(true);
     }
 
 

Added: jmeter/trunk/src/core/org/apache/jmeter/gui/action/SearchTreeDialog.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/SearchTreeDialog.java?rev=1197425&view=auto
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/SearchTreeDialog.java (added)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/SearchTreeDialog.java Fri Nov  4 08:34:07
2011
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.gui.action;
+
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.jmeter.gui.GuiPackage;
+import org.apache.jmeter.gui.Searchable;
+import org.apache.jmeter.gui.tree.JMeterTreeModel;
+import org.apache.jmeter.gui.tree.JMeterTreeNode;
+import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jorphan.gui.ComponentUtil;
+import org.apache.jorphan.gui.JLabeledTextField;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+
+/**
+ * 
+ */
+public class SearchTreeDialog extends JDialog implements ActionListener {
+    /**
+	 * 
+	 */
+	private static final long serialVersionUID = -4436834972710248247L;
+
+	private Logger logger = LoggingManager.getLoggerForClass();
+
+    private JButton searchButton;
+    
+	private JLabeledTextField searchTF;
+	
+	private JCheckBox isRegexpCB;
+
+	private JCheckBox isCaseSensitiveCB;
+
+	private JButton cancelButton;
+
+
+	public SearchTreeDialog() {
+        super((JFrame) null, JMeterUtils.getResString("search_tree_title"), true); //$NON-NLS-1$
+        init();
+    }
+
+    private void init() {
+        this.getContentPane().setLayout(new BorderLayout(10,10));
+
+        searchTF = new JLabeledTextField(JMeterUtils.getResString("search_text_field"), 20);
//$NON-NLS-1$
+        isRegexpCB = new JCheckBox(JMeterUtils.getResString("search_text_chkbox_regexp"),
false); //$NON-NLS-1$
+        isCaseSensitiveCB = new JCheckBox(JMeterUtils.getResString("search_text_chkbox_case"),
false); //$NON-NLS-1$
+
+        JPanel searchCriterionPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
+        searchCriterionPanel.add(isCaseSensitiveCB);
+        searchCriterionPanel.add(isRegexpCB);
+        
+        this.getContentPane().add(searchTF, BorderLayout.NORTH);
+        this.getContentPane().add(searchCriterionPanel, BorderLayout.CENTER);
+        JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
+        
+        searchButton = new JButton(JMeterUtils.getResString("search")); //$NON-NLS-1$
+        searchButton.addActionListener(this);
+        cancelButton = new JButton(JMeterUtils.getResString("cancel")); //$NON-NLS-1$
+        cancelButton.addActionListener(this);
+        buttonsPanel.add(searchButton);
+        buttonsPanel.add(cancelButton);
+        this.getContentPane().add(buttonsPanel, BorderLayout.SOUTH);
+        this.pack();
+        ComponentUtil.centerComponentInWindow(this);
+    }
+
+
+    public void actionPerformed(ActionEvent e) {
+    	if(e.getSource()==cancelButton) {
+    		this.setVisible(false);
+    		return;
+    	} 
+    	
+    	String wordToSearch = searchTF.getText();
+    	if(StringUtils.isEmpty(wordToSearch)) {
+            return;
+        }
+    	
+    	// reset previous result
+    	ActionRouter.getInstance().doActionNow(new ActionEvent(e.getSource(), e.getID(), ActionNames.SEARCH_RESET));
+        // do search
+    	Searcher searcher = null; 
+    	if(isRegexpCB.isSelected()) {
+    		searcher = new RegexpSearcher(isCaseSensitiveCB.isSelected(), searchTF.getText());
+    	} else {
+    		searcher = new RawTextSearcher(isCaseSensitiveCB.isSelected(), searchTF.getText());
+    	}
+        GuiPackage guiPackage = GuiPackage.getInstance();
+        JMeterTreeModel jMeterTreeModel = guiPackage.getTreeModel();
+        Set<JMeterTreeNode> nodes = new HashSet<JMeterTreeNode>();
+        for (JMeterTreeNode jMeterTreeNode : jMeterTreeModel.getNodesOfType(Searchable.class))
{
+            try {
+                if (jMeterTreeNode.getUserObject() instanceof Searchable){
+                    Searchable searchable = (Searchable) jMeterTreeNode.getUserObject();
+                    List<JMeterTreeNode> matchingNodes = jMeterTreeNode.getPathToThreadGroup();
+                    List<String> searchableTokens = searchable.getSearchableTokens();
+                    boolean result = searcher.search(searchableTokens);
+                    if(result) {
+                        nodes.addAll(matchingNodes);
+                    }
+                }
+            } catch (Exception ex) {
+                logger.error("Error occured searching for word:"+ wordToSearch, ex);
+            }
+        }
+        for (Iterator<JMeterTreeNode> iterator = nodes.iterator(); iterator.hasNext();)
{
+            JMeterTreeNode jMeterTreeNode = iterator.next();
+            jMeterTreeNode.setMarkedBySearch(true);
+        }
+        GuiPackage.getInstance().getMainFrame().repaint();
+        this.setVisible(false);
+    }
+}
\ No newline at end of file

Propchange: jmeter/trunk/src/core/org/apache/jmeter/gui/action/SearchTreeDialog.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jmeter/trunk/src/core/org/apache/jmeter/gui/action/Searcher.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/Searcher.java?rev=1197425&view=auto
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/Searcher.java (added)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/Searcher.java Fri Nov  4 08:34:07 2011
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.jmeter.gui.action;
+
+import java.util.List;
+
+/**
+ * Search algorithm
+ */
+public interface Searcher {
+
+	/**
+	 * Implements the search
+	 * @param textTokens List<String> content to be searched
+	 * @return true if search on textTokens is successful
+	 */
+	boolean search(List<String> textTokens);
+}

Propchange: jmeter/trunk/src/core/org/apache/jmeter/gui/action/Searcher.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties?rev=1197425&r1=1197424&r2=1197425&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties Fri Nov  4 08:34:07
2011
@@ -773,7 +773,7 @@ search_text_field=Search: 
 search_text_msg_not_found=Text not found
 search_text_title_not_found=Not found
 search_tree_title=Search Tree
-search_word=Search Word
+search=Search
 searchbase=Search base
 searchfilter=Search Filter
 searchtest=Search test

Modified: jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractScopedTestElement.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractScopedTestElement.java?rev=1197425&r1=1197424&r2=1197425&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractScopedTestElement.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractScopedTestElement.java Fri
Nov  4 08:34:07 2011
@@ -157,18 +157,13 @@ public abstract class AbstractScopedTest
         return sampleList;
     }
     
-    /**
-     * {@inheritDoc}
+    /** 
+     * {@inheritDoc}}
      */
     @Override
-    public boolean searchContent(String textToSearch) throws Exception {
-        if(super.searchContent(textToSearch)) {
-            return true;
-        }
-        String searchedTextLowerCase = textToSearch.toLowerCase();
-        if(testField(getVariableName(), searchedTextLowerCase)) {
-            return true;
-        }
-        return false;
+    public List<String> getSearchableTokens() throws Exception {
+        List<String> result = super.getSearchableTokens();
+        result.add(getVariableName());
+        return result;
     }
 }

Modified: jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractTestElement.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractTestElement.java?rev=1197425&r1=1197424&r2=1197425&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractTestElement.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractTestElement.java Fri Nov 
4 08:34:07 2011
@@ -19,14 +19,15 @@
 package org.apache.jmeter.testelement;
 
 import java.io.Serializable;
+import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
-import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.commons.lang.StringUtils;
 import org.apache.jmeter.gui.Searchable;
 import org.apache.jmeter.testelement.property.BooleanProperty;
 import org.apache.jmeter.testelement.property.CollectionProperty;
@@ -524,30 +525,13 @@ public abstract class AbstractTestElemen
         return getProperty(TestElement.ENABLED) instanceof NullProperty || getPropertyAsBoolean(TestElement.ENABLED);
     }
     
-    /**
-     * {@inheritDoc}
+    /** 
+     * {@inheritDoc}}
      */
-    public boolean searchContent(String textToSearch) throws Exception {
-        String searchedTextLowerCase = textToSearch.toLowerCase();
-        if(testField(getComment(), searchedTextLowerCase)) {
-            return true;
-        }
-        if(testField(getName(), searchedTextLowerCase)) {
-            return true;
-        }
-        return false;
-    }
-    
-    /**
-     * Returns true if searchedTextLowerCase is in value
-     * @param value
-     * @param searchedTextLowerCase
-     * @return true if searchedTextLowerCase is in value
-     */
-    protected boolean testField(String value, String searchedTextLowerCase) {
-        if(!StringUtils.isEmpty(value)) {
-            return value.toLowerCase().indexOf(searchedTextLowerCase)>=0;
-        }
-        return false;
+    public List<String> getSearchableTokens() throws Exception {
+        List<String> result = new ArrayList<String>(2);
+        result.add(getComment());
+        result.add(getName());
+        return result;
     }
 }

Modified: jmeter/trunk/src/core/org/apache/jmeter/util/BeanShellTestElement.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/util/BeanShellTestElement.java?rev=1197425&r1=1197424&r2=1197425&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/util/BeanShellTestElement.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/util/BeanShellTestElement.java Fri Nov  4 08:34:07
2011
@@ -19,6 +19,7 @@
 package org.apache.jmeter.util;
 
 import java.io.Serializable;
+import java.util.List;
 
 import org.apache.jmeter.engine.event.LoopIterationEvent;
 import org.apache.jmeter.testelement.AbstractTestElement;
@@ -27,8 +28,6 @@ import org.apache.jmeter.testelement.Thr
 import org.apache.jmeter.threads.JMeterContext;
 import org.apache.jmeter.threads.JMeterContextService;
 import org.apache.jmeter.threads.JMeterVariables;
-import org.apache.jmeter.util.BeanShellInterpreter;
-import org.apache.jmeter.util.JMeterUtils;
 import org.apache.jorphan.logging.LoggingManager;
 import org.apache.jorphan.util.JMeterException;
 import org.apache.jorphan.util.JOrphanUtils;
@@ -280,18 +279,13 @@ public abstract class BeanShellTestEleme
         resetInterpreter = b;
     }
     
-    /**
-     * {@inheritDoc}
+    /** 
+     * {@inheritDoc}}
      */
     @Override
-    public boolean searchContent(String textToSearch) throws Exception {
-        if(super.searchContent(textToSearch)) {
-            return true;
-        }
-        String searchedTextLowerCase = textToSearch.toLowerCase();
-        if(testField(getScript(), searchedTextLowerCase)) {
-            return true;
-        }
-        return false;
+    public List<String> getSearchableTokens() throws Exception {
+        List<String> result = super.getSearchableTokens();
+        result.add(getScript());
+        return result;
     }
 }

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java?rev=1197425&r1=1197424&r2=1197425&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
Fri Nov  4 08:34:07 2011
@@ -1815,33 +1815,23 @@ public abstract class HTTPSamplerBase ex
         }
     }
     
-    /**
+    
+    /** 
      * We search in URL and arguments
-     * TODO Can be enhanced
-     * {@inheritDoc}
+     * {@inheritDoc}}
      */
     @Override
-    public boolean searchContent(String textToSearch) throws Exception {
-        if(super.searchContent(textToSearch)) {
-            return true;
-        }
-        String searchedTextLowerCase = textToSearch.toLowerCase();
-        if(testField(getUrl().toString(), searchedTextLowerCase)) {
-            return true;
-        }
+    public List<String> getSearchableTokens() throws Exception {
+        List<String> result = super.getSearchableTokens();
+        result.add(getUrl().toExternalForm());
         Arguments arguments = getArguments();
         if(arguments != null) {
             for (int i = 0; i < arguments.getArgumentCount(); i++) {
                 Argument argument = arguments.getArgument(i);
-                if(testField(argument.getName(), searchedTextLowerCase)) {
-                    return true;
-                }
-                if(testField(argument.getValue(), searchedTextLowerCase)) {
-                    return true;
-                }
+                result.add(argument.getName());
+                result.add(argument.getValue());
             }
         }
-        return false;
+        return result;
     }
- }
-
+}
\ No newline at end of file



Mime
View raw message