Return-Path: X-Original-To: apmail-jmeter-user-archive@www.apache.org Delivered-To: apmail-jmeter-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E034017939 for ; Fri, 4 Sep 2015 11:37:27 +0000 (UTC) Received: (qmail 33244 invoked by uid 500); 4 Sep 2015 11:37:27 -0000 Delivered-To: apmail-jmeter-user-archive@jmeter.apache.org Received: (qmail 33206 invoked by uid 500); 4 Sep 2015 11:37:27 -0000 Mailing-List: contact user-help@jmeter.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "JMeter Users List" Delivered-To: mailing list user@jmeter.apache.org Received: (qmail 33192 invoked by uid 99); 4 Sep 2015 11:37:27 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Sep 2015 11:37:27 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id AF54E1AB5F0 for ; Fri, 4 Sep 2015 11:37:26 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.129 X-Spam-Level: *** X-Spam-Status: No, score=3.129 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, HTML_MESSAGE=3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id O3LidfLmvWyV for ; Fri, 4 Sep 2015 11:37:23 +0000 (UTC) Received: from mail-ig0-f179.google.com (mail-ig0-f179.google.com [209.85.213.179]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id 0279C20EFD for ; Fri, 4 Sep 2015 11:37:23 +0000 (UTC) Received: by igbkq10 with SMTP id kq10so10124699igb.0 for ; Fri, 04 Sep 2015 04:37:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=goyrUaxF5jVHYx6ypX/JPZXIgcRY2uH46MU3SqGN0T4=; b=PyniOnPBY08gED51bIYi++MKxD0ypNYo7ilIstk5MkiDCCIL1YbLKbktvrB8G1USh8 ACo/cHP+mUbxFpbWnFcn/9l2yNNgbkrLH1wNv9sFLps10ABCZbnY732o3qT2bPHSkOeb gzHttDWGqsxIjelbvXwdtehu1u7P8w0loI2v/IBQz8EHrjfrvb6g8ly7nEq8lg1OP8vI gZnq94lYvyIWLNlBXBEaZ1LvY02S0lBIGKarEUjfxR+hgQjt4T2HJdKljrXIMyIpccz2 vFvx3jgALdHokYobpHtEZalWPkLYkrvOo2iRle4dQQts2y0/6onhENkQI3uDKf1on1fE Q7+A== MIME-Version: 1.0 X-Received: by 10.50.43.197 with SMTP id y5mr6390022igl.89.1441366641987; Fri, 04 Sep 2015 04:37:21 -0700 (PDT) Received: by 10.107.186.68 with HTTP; Fri, 4 Sep 2015 04:37:21 -0700 (PDT) In-Reply-To: References: Date: Fri, 4 Sep 2015 13:37:21 +0200 Message-ID: Subject: Re: Setting user defined variable in beanshell not working From: Peter Moser To: JMeter Users List Content-Type: multipart/alternative; boundary=089e01182608afd7b9051eea52a1 --089e01182608afd7b9051eea52a1 Content-Type: text/plain; charset=UTF-8 Hi, thanks for your answer. The variables in the Testplan are static. So I have no opportunity at runtime to load JDBC Configurations from a config file? Best regards 2015-09-04 13:25 GMT+02:00 sebb : > That's because the JDBC Config element processes variables at > configuration time, which occurs before the samplers are run. > > Try defining the variable on the Test Plan and you should see the > difference > > On 4 September 2015 at 11:31, Peter Moser wrote: > > Hi, > > > > I want to set user defined variables in a beanshell. > > I use this code: vars.put("user", "one"), > > > > When I later want to use the variable in a sampler with ${user}, it is > not > > replaced. > > With a debug sampler I can see the variable is set. > > > > > > What am I doing wrong? Here is the xml of the project: > > > > > > > > > > > > > > false > > false > > > elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" > > testname="User Defined Variables" enabled="true"> > > > > > > > > > > > > > testname="Thread Group" enabled="true"> > > name="ThreadGroup.on_sample_error">continue > > > elementType="LoopController" guiclass="LoopControlPanel" > > testclass="LoopController" testname="Loop Controller" enabled="true"> > > name="LoopController.continue_forever">false > > 1 > > > > 1 > > 1 > > 1441359197000 > > 1441359197000 > > false > > > > > > > > > > > testclass="BeanShellSampler" testname="BeanShell Sampler" enabled="true"> > > > name="BeanShellSampler.query">vars.put("user", > "one"); > > vars.put("host", "localhost"); > > > > > > > name="BeanShellSampler.resetInterpreter">false > > > > > > > testname="JDBC Connection Configuration" enabled="true"> > > dbcon > > 10 > > 10000 > > 60000 > > true > > DEFAULT > > true > > 5000 > > Select 1 > > > name="dbUrl">jdbc:postgresql://localhost:5432/box > > org.postgresql.Driver > > ${user} > > pwd > > > > > > > testname="JDBC Request" enabled="true"> > > dbcon > > Select Statement > > SELECT 1 > > > > > > > > > > > > Store as > String > > > > > > > testclass="ResultCollector" testname="View Results Tree" enabled="true"> > > false > > > > saveConfig > > > > > > true > > true > > true > > > > true > > true > > true > > true > > false > > true > > true > > false > > false > > false > > false > > false > > false > > false > > > > > false > > 0 > > true > > true > > > > > > > > > > > > > > > > > > > > > > > > Error that I got: > > FATAL: role "${user}" does not exist > > > > Best regards, Peter > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org > For additional commands, e-mail: user-help@jmeter.apache.org > > --089e01182608afd7b9051eea52a1--