Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BSF elements do not load script files, attempt to interpret filename as script #2182

Closed
asfimport opened this issue Dec 16, 2008 · 3 comments

Comments

@asfimport
Copy link
Collaborator

Thomas Johnson (Bug 46407):
When specifying a script file in the BSF post-processor, the filename is treated as a code snippet instead of being loaded, taking precedence over the regular script.

This likely also affects the BSF Preprocessor, Assertion, and Listener, as they all call the BSFTestElement.processFileOrScript(BSFManager) method. The processFileOrScript method currently takes the filename and passes it directly to the script manager for evaluation instead of loading the file and passing its contents to the script manager.

Steps to Reproduce:

  • Create new Test Plan
  • Add a new Thread Group
  • Add a new sampler (tested with a Debug Sampler)
  • Add a new BSF Postprocessor
  • Choose an available BSF language (Tested with "javascript")
  • Input valid javascript as filename (Tested with OUT.println("--- filename ---"))
  • Input valid javascript as script (Tested with OUT.println("--- script ---");)
  • Execute test

Expected Results:

  • Postprocessor fails, unable to find file

Actual Results:

  • Console output: "--- filename ---"

Version: Nightly
Severity: normal
OS: Mac OS X 10.4

@asfimport
Copy link
Collaborator Author

Thomas Johnson (migrated from Bugzilla):
Created attachment execute-filename.jmx: Test case illustrating issue (watch the console output)

execute-filename.jmx
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="2.1">
  <hashTree>
    <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
      <stringProp name="TestPlan.comments"></stringProp>
      <boolProp name="TestPlan.functional_mode">false</boolProp>
      <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
      <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
        <collectionProp name="Arguments.arguments"/>
      </elementProp>
      <stringProp name="TestPlan.user_define_classpath"></stringProp>
    </TestPlan>
    <hashTree>
      <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
        <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
          <boolProp name="LoopController.continue_forever">false</boolProp>
          <stringProp name="LoopController.loops">1</stringProp>
        </elementProp>
        <stringProp name="ThreadGroup.num_threads">1</stringProp>
        <stringProp name="ThreadGroup.ramp_time">1</stringProp>
        <longProp name="ThreadGroup.start_time">1229443625000</longProp>
        <longProp name="ThreadGroup.end_time">1229443625000</longProp>
        <boolProp name="ThreadGroup.scheduler">false</boolProp>
        <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
        <stringProp name="ThreadGroup.duration"></stringProp>
        <stringProp name="ThreadGroup.delay"></stringProp>
      </ThreadGroup>
      <hashTree>
        <DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="Debug Sampler" enabled="true">
          <boolProp name="displayJMeterProperties">false</boolProp>
          <boolProp name="displayJMeterVariables">true</boolProp>
          <boolProp name="displaySystemProperties">false</boolProp>
        </DebugSampler>
        <hashTree>
          <BSFPostProcessor guiclass="TestBeanGUI" testclass="BSFPostProcessor" testname="BSF PostProcessor" enabled="true">
            <stringProp name="filename">OUT.println(&quot;--- filename ---&quot;)</stringProp>
            <stringProp name="parameters"></stringProp>
            <stringProp name="script">OUT.println(&quot;--- script ---&quot;)</stringProp>
            <stringProp name="scriptLanguage">javascript</stringProp>
          </BSFPostProcessor>
          <hashTree/>
        </hashTree>
      </hashTree>
    </hashTree>
  </hashTree>
</jmeterTestPlan>

@asfimport
Copy link
Collaborator Author

Thomas Johnson (migrated from Bugzilla):
Affects nightly build from r724447

@asfimport
Copy link
Collaborator Author

Sebb (migrated from Bugzilla):
Thanks for the bug report.

The code for processing script files was completely broken - it did not bother reading the file - oops!

Fixed in SVN in r728228.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant