You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2009/10/23 19:18:19 UTC

svn commit: r829133 - in /jakarta/jmeter/trunk/src: components/org/apache/jmeter/extractor/ components/org/apache/jmeter/modifiers/ components/org/apache/jmeter/visualizers/ core/org/apache/jmeter/util/

Author: sebb
Date: Fri Oct 23 17:18:19 2009
New Revision: 829133

URL: http://svn.apache.org/viewvc?rev=829133&view=rev
Log:
Bug47952 - Initial JSR223 test element implementation

Added:
    jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/JSR223PostProcessor.java   (with props)
    jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/JSR223PostProcessorBeanInfo.java   (with props)
    jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/JSR223PostProcessorResources.properties   (with props)
    jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/JSR223PreProcessor.java   (with props)
    jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/JSR223PreProcessorBeanInfo.java   (with props)
    jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/JSR223PreProcessorResources.properties   (with props)
    jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/JSR223PreProcessorResources_fr.properties   (with props)
    jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/JSR223Listener.java   (with props)
    jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/JSR223ListenerBeanInfo.java   (with props)
    jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/JSR223ListenerResources.properties   (with props)
    jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/JSR223ListenerResources_fr.properties   (with props)
    jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/JSR223TestElement.java   (with props)

Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/JSR223PostProcessor.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/JSR223PostProcessor.java?rev=829133&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/JSR223PostProcessor.java (added)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/JSR223PostProcessor.java Fri Oct 23 17:18:19 2009
@@ -0,0 +1,55 @@
+/*
+ * 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.extractor;
+
+import java.io.IOException;
+
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+
+import org.apache.jmeter.processor.PostProcessor;
+import org.apache.jmeter.testbeans.TestBean;
+import org.apache.jmeter.util.JSR223TestElement;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+
+public class JSR223PostProcessor extends JSR223TestElement implements Cloneable, PostProcessor, TestBean
+{
+    private static final Logger log = LoggingManager.getLoggerForClass();
+
+    private static final long serialVersionUID = 232L;
+
+    public void process() {
+    	
+    	ScriptEngineManager sem = null;
+    	try {
+    		sem = getManager();
+    	} catch(Exception e) {
+    		e.printStackTrace();
+    	}
+    	
+    	if(sem == null) { return; }
+    	try {
+    		processFileOrScript(sem);
+    	} catch (Exception e) {
+    		e.printStackTrace();
+		}
+
+    }
+}

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/JSR223PostProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/JSR223PostProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/JSR223PostProcessorBeanInfo.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/JSR223PostProcessorBeanInfo.java?rev=829133&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/JSR223PostProcessorBeanInfo.java (added)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/JSR223PostProcessorBeanInfo.java Fri Oct 23 17:18:19 2009
@@ -0,0 +1,29 @@
+/*
+ * 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.extractor;
+
+import org.apache.jmeter.util.BSFBeanInfoSupport;
+
+public class JSR223PostProcessorBeanInfo extends BSFBeanInfoSupport {
+
+    public JSR223PostProcessorBeanInfo() {
+        super(JSR223PostProcessor.class);
+    }
+
+}

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/JSR223PostProcessorBeanInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/JSR223PostProcessorBeanInfo.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/JSR223PostProcessorResources.properties
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/JSR223PostProcessorResources.properties?rev=829133&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/JSR223PostProcessorResources.properties (added)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/JSR223PostProcessorResources.properties Fri Oct 23 17:18:19 2009
@@ -0,0 +1,28 @@
+#   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.
+
+displayName=JSR223 PostProcessor
+scriptingLanguage.displayName=Script language (e.g. groovy, javascript, jexl)
+scriptLanguage.displayName=Language
+scriptLanguage.shortDescription=Name of JSR223 language, e.g. beanshell, javascript, jexl
+scripting.displayName=Script (variables: ctx vars props prev sampler log Label Filename Parameters args[] OUT)
+script.displayName=Script
+script.shortDescription=Script in the appropriate JSR223 language
+parameterGroup.displayName=Parameters to be passed to script (=> String Parameters and String []args)
+parameters.displayName=Parameters
+parameters.shortDescription=Parameters to be passed to the file or script
+filenameGroup.displayName=Script file (overrides script)
+filename.displayName=File Name
+filename.shortDescription=Script file (overrides script)
\ No newline at end of file

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/extractor/JSR223PostProcessorResources.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/JSR223PreProcessor.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/JSR223PreProcessor.java?rev=829133&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/JSR223PreProcessor.java (added)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/JSR223PreProcessor.java Fri Oct 23 17:18:19 2009
@@ -0,0 +1,45 @@
+/*
+ * 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.modifiers;
+
+import javax.script.ScriptEngineManager;
+
+import org.apache.jmeter.processor.PreProcessor;
+import org.apache.jmeter.testbeans.TestBean;
+import org.apache.jmeter.util.JSR223TestElement;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+
+public class JSR223PreProcessor extends JSR223TestElement implements Cloneable, PreProcessor, TestBean
+{
+    private static final Logger log = LoggingManager.getLoggerForClass();
+
+    private static final long serialVersionUID = 232L;
+
+    public void process() {
+
+        try {
+        	ScriptEngineManager sem = getManager();
+        	if(sem == null) { return; }
+        	processFileOrScript(sem);
+        } catch (Exception e) {
+        	log.warn("Problem in JSR223 script " + e);
+		}
+    }
+}

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/JSR223PreProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/JSR223PreProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/JSR223PreProcessorBeanInfo.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/JSR223PreProcessorBeanInfo.java?rev=829133&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/JSR223PreProcessorBeanInfo.java (added)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/JSR223PreProcessorBeanInfo.java Fri Oct 23 17:18:19 2009
@@ -0,0 +1,29 @@
+/*
+ * 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.modifiers;
+
+import org.apache.jmeter.util.BSFBeanInfoSupport;
+
+public class JSR223PreProcessorBeanInfo extends BSFBeanInfoSupport {
+
+    public JSR223PreProcessorBeanInfo() {
+        super(JSR223PreProcessor.class);
+    }
+
+}
\ No newline at end of file

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/JSR223PreProcessorBeanInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/JSR223PreProcessorBeanInfo.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/JSR223PreProcessorResources.properties
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/JSR223PreProcessorResources.properties?rev=829133&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/JSR223PreProcessorResources.properties (added)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/JSR223PreProcessorResources.properties Fri Oct 23 17:18:19 2009
@@ -0,0 +1,28 @@
+#   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.
+
+displayName=JSR223 PreProcessor
+scriptingLanguage.displayName=Script language (e.g. groovy, jython, jruby)
+scriptLanguage.displayName=Language
+scriptLanguage.shortDescription=Name of JSR223 language, e.g. groovy, jython, jruby
+scripting.displayName=Script (variables: ctx vars props prev sampler log Label Filename Parameters args[] OUT)
+script.displayName=Script
+script.shortDescription=Script in the appropriate JSR223 language
+parameterGroup.displayName=Parameters to be passed to script (=> String Parameters and String []args)
+parameters.displayName=Parameters
+parameters.shortDescription=Parameters to be passed to the file or script
+filenameGroup.displayName=Script file (overrides script)
+filename.displayName=File Name
+filename.shortDescription=Script file (overrides script)
\ No newline at end of file

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/JSR223PreProcessorResources.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/JSR223PreProcessorResources_fr.properties
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/JSR223PreProcessorResources_fr.properties?rev=829133&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/JSR223PreProcessorResources_fr.properties (added)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/JSR223PreProcessorResources_fr.properties Fri Oct 23 17:18:19 2009
@@ -0,0 +1,29 @@
+#   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.
+
+#Stored by I18NEdit, may be edited!
+displayName=Pr\u00E9-Processeur JSR223
+filename.displayName=Nom de fichier 
+filename.shortDescription=Fichier de script (remplace le script)
+filenameGroup.displayName=Fichier de script (remplace le script)
+parameterGroup.displayName=Param\u00E8tres \u00E0 passer au script (\=> String Parameters and String []args)
+parameters.displayName=Param\u00E8tres
+parameters.shortDescription=Param\u00E8tres \u00E0 passer au fichier ou au script
+script.displayName=Script
+script.shortDescription=Script dans le langage JSR223 appropri\u00E9
+scriptLanguage.displayName=Langage 
+scriptLanguage.shortDescription=Nom du langage JSR223, i.e. groovy, jython, jruby
+scripting.displayName=Script (variables\: ctx vars props prev sampler log Label Filename Parameters args[] OUT)
+scriptingLanguage.displayName=Langage de script (i.e. beanshell, javascript, jexl)

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/JSR223PreProcessorResources_fr.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/JSR223Listener.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/JSR223Listener.java?rev=829133&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/JSR223Listener.java (added)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/JSR223Listener.java Fri Oct 23 17:18:19 2009
@@ -0,0 +1,70 @@
+/*
+ * 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.visualizers;
+
+import javax.script.ScriptEngineManager;
+
+import org.apache.bsf.BSFException;
+import org.apache.bsf.BSFManager;
+import org.apache.jmeter.samplers.SampleEvent;
+import org.apache.jmeter.samplers.SampleListener;
+import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jmeter.testbeans.TestBean;
+import org.apache.jmeter.util.BSFTestElement;
+import org.apache.jmeter.util.JSR223TestElement;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+
+public class JSR223Listener extends JSR223TestElement 
+    implements Cloneable, SampleListener, TestBean, Visualizer {
+// N.B. Needs to implement Visualizer so that TestBeanGUI can find the correct GUI class
+
+    private static final Logger log = LoggingManager.getLoggerForClass();
+    
+    private static final long serialVersionUID = 234L;
+    
+    public void sampleOccurred(SampleEvent event) {
+        try {
+            ScriptEngineManager sem = getManager();
+            if (sem == null) {
+                log.error("Problem creating JSR 223 manager");
+                return; 
+            }
+            sem.put("sampleEvent", SampleEvent.class);
+            SampleResult result = event.getResult();
+            sem.put("sampleResult", SampleResult.class);
+            processFileOrScript(sem);
+        } catch (Exception e) {
+            log.warn("Problem in JSR 223 script " + e);
+        }
+    }
+
+    public void sampleStarted(SampleEvent e) {
+    }
+
+    public void sampleStopped(SampleEvent e) {
+    }
+
+    public void add(SampleResult sample) {
+    }
+
+    public boolean isStats() {
+        return false;
+    }
+}

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/JSR223Listener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/JSR223Listener.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/JSR223ListenerBeanInfo.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/JSR223ListenerBeanInfo.java?rev=829133&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/JSR223ListenerBeanInfo.java (added)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/JSR223ListenerBeanInfo.java Fri Oct 23 17:18:19 2009
@@ -0,0 +1,29 @@
+/*
+ * 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.visualizers;
+
+import org.apache.jmeter.util.BSFBeanInfoSupport;
+
+public class JSR223ListenerBeanInfo extends BSFBeanInfoSupport {
+
+    public JSR223ListenerBeanInfo() {
+        super(JSR223Listener.class);
+    }
+
+}

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/JSR223ListenerBeanInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/JSR223ListenerBeanInfo.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/JSR223ListenerResources.properties
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/JSR223ListenerResources.properties?rev=829133&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/JSR223ListenerResources.properties (added)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/JSR223ListenerResources.properties Fri Oct 23 17:18:19 2009
@@ -0,0 +1,28 @@
+#   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.
+
+displayName=JSR 223 Listener
+scriptingLanguage.displayName=Script language (e.g. beanshell, javascript, jexl)
+scriptLanguage.displayName=Language
+scriptLanguage.shortDescription=Name of JSR 223 language, e.g. beanshell, javascript, jexl
+scripting.displayName=Script (variables: ctx vars props sampleResult (aka prev) sampleEvent sampler log Label Filename Parameters args[] OUT)
+script.displayName=Script
+script.shortDescription=Script in the appropriate JSR 223 language
+parameterGroup.displayName=Parameters to be passed to script (=> String Parameters and String []args)
+parameters.displayName=Parameters
+parameters.shortDescription=Parameters to be passed to the file or script
+filenameGroup.displayName=Script file (overrides script)
+filename.displayName=File Name
+filename.shortDescription=Script file (overrides script)
\ No newline at end of file

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/JSR223ListenerResources.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/JSR223ListenerResources_fr.properties
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/JSR223ListenerResources_fr.properties?rev=829133&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/JSR223ListenerResources_fr.properties (added)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/JSR223ListenerResources_fr.properties Fri Oct 23 17:18:19 2009
@@ -0,0 +1,29 @@
+#   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.
+
+#Stored by I18NEdit, may be edited!
+displayName=R\u00E9cepteur JSR 223
+filename.displayName=Nom de fichier 
+filename.shortDescription=Fichier de script (remplace le script)
+filenameGroup.displayName=Fichier de script (remplace le script)
+parameterGroup.displayName=Param\u00E8tres \u00E0 passer au script (\=> String Parameters and String []args)
+parameters.displayName=Param\u00E8tres 
+parameters.shortDescription=Param\u00E8tres \u00E0 passer au fichier ou au script
+script.displayName=Script 
+script.shortDescription=Script dans le langage JSR 223 appropri\u00E9
+scriptLanguage.displayName=Langage 
+scriptLanguage.shortDescription=Nom du langage JSR 223, i.e. beanshell, javascript, jexl
+scripting.displayName=Script (variables \: ctx vars props sampleResult (aka prev) sampleEvent sampler log Label Filename Parameters args[] OUT)
+scriptingLanguage.displayName=Langage de script (i.e. groovy, beanshell, jexl)

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/JSR223ListenerResources_fr.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/JSR223TestElement.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/JSR223TestElement.java?rev=829133&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/JSR223TestElement.java (added)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/JSR223TestElement.java Fri Oct 23 17:18:19 2009
@@ -0,0 +1,197 @@
+/*
+ * 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.util;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.Serializable;
+import java.util.Properties;
+
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+
+import org.apache.bsf.BSFEngine;
+import org.apache.bsf.BSFException;
+import org.apache.bsf.BSFManager;
+import org.apache.commons.io.FileUtils;
+import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jmeter.samplers.Sampler;
+import org.apache.jmeter.testelement.AbstractTestElement;
+import org.apache.jmeter.threads.JMeterContext;
+import org.apache.jmeter.threads.JMeterContextService;
+import org.apache.jmeter.threads.JMeterVariables;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.jorphan.util.JOrphanUtils;
+import org.apache.log.Logger;
+
+import sun.security.action.GetLongAction;
+
+public abstract class JSR223TestElement extends AbstractTestElement
+    implements Serializable, Cloneable
+{
+    private static final long serialVersionUID = 233L;
+    
+    private static final Logger log = LoggingManager.getLoggerForClass();
+
+    //++ For TestBean implementations only
+    private String parameters; // passed to file or script
+
+    private String filename; // file to source (overrides script)
+
+    private String script; // script (if file not provided)
+
+    private String scriptLanguage; // JSR223 language to use
+    //-- For TestBean implementations only
+
+    public JSR223TestElement() {
+        super();
+        init();
+    }
+
+    private void init() {
+        parameters=""; // ensure variables are not null
+        filename="";
+        script="";
+        scriptLanguage="";
+    }
+
+    protected Object readResolve() {
+        init();
+        return this;
+    }
+
+    public Object clone() {
+        JSR223TestElement o = (JSR223TestElement) super.clone();
+        o.init();
+       return o;
+    }
+
+    protected ScriptEngineManager getManager() {
+    	ScriptEngineManager sem = new ScriptEngineManager();
+    	initManager(sem);
+    	return sem;
+    }
+
+    protected void initManager(ScriptEngineManager sem) {
+    	final String label = getName();
+        final String fileName = getFilename();
+        final String scriptParameters = getParameters();
+        // Use actual class name for log
+        final Logger logger = LoggingManager.getLoggerForShortName(getClass().getName());
+        
+        sem.put("log", logger);
+        sem.put("Label", label);
+        sem.put("FileName", fileName);
+        sem.put("Parameters", scriptParameters);
+        String [] args=JOrphanUtils.split(scriptParameters, " ");//$NON-NLS-1$
+        sem.put("args", args);
+        // Add variables for access to context and variables
+        JMeterContext jmctx = JMeterContextService.getContext();
+        sem.put("ctx", jmctx);
+        JMeterVariables vars = jmctx.getVariables();
+        sem.put("vars", vars);
+        Properties props = JMeterUtils.getJMeterProperties();
+        sem.put("props", props);
+        // For use in debugging:
+        sem.put("OUT", System.out);
+
+        // Most subclasses will need these:
+        Sampler sampler = jmctx.getCurrentSampler();
+        sem.put("sampler", sampler);
+        SampleResult prev = jmctx.getPreviousResult();
+        sem.put("prev", prev);
+    }
+
+    
+    protected void processFileOrScript(ScriptEngineManager sem) throws IOException, ScriptException {
+    	
+    	ScriptEngine scriptEngine = sem.getEngineByName(getScriptLanguage());
+    	if (scriptEngine == null) {
+    		log.warn("Not supported scripting engine");
+    		setScriptLanguage("groovy");
+    		scriptEngine = sem.getEngineByName(getScriptLanguage());
+    	} else {
+    		System.out.println("Script engine found : " + getScriptLanguage());
+    	}
+    	
+    	File scriptFile = new File(getFilename());
+    	if (scriptFile.exists()) {
+    		BufferedReader fileReader = new BufferedReader(new FileReader(scriptFile));
+    		String line;
+    		while ((line = fileReader.readLine()) != null) {
+    			scriptEngine.eval(line);
+    		}
+    	} else {
+    		scriptEngine.eval(getScript());
+    	}
+    	
+    }
+
+    /**
+     * Return the script (TestBean version).
+     * Must be overridden for subclasses that don't implement TestBean
+     * otherwise the clone() method won't work.
+     *
+     * @return the script to execute
+     */
+    public String getScript(){
+        return script;
+    }
+
+    /**
+     * Set the script (TestBean version).
+     * Must be overridden for subclasses that don't implement TestBean
+     * otherwise the clone() method won't work.
+     *
+     * @param s the script to execute (may be blank)
+     */
+    public void setScript(String s){
+        script=s;
+    }
+
+    public String getParameters() {
+        return parameters;
+    }
+
+    public void setParameters(String s) {
+        parameters = s;
+    }
+
+    public String getFilename() {
+        return filename;
+    }
+
+    public void setFilename(String s) {
+        filename = s;
+    }
+
+    public String getScriptLanguage() {
+        return scriptLanguage;
+    }
+
+    public void setScriptLanguage(String s) {
+        scriptLanguage = s;
+    }
+
+}

Propchange: jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/JSR223TestElement.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/jmeter/trunk/src/core/org/apache/jmeter/util/JSR223TestElement.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org