From user-return-47530-archive-asf-public=cust-asf.ponee.io@jmeter.apache.org Fri May 10 13:37:54 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 8249318061A for ; Fri, 10 May 2019 15:37:54 +0200 (CEST) Received: (qmail 98242 invoked by uid 500); 10 May 2019 13:37:52 -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 98231 invoked by uid 99); 10 May 2019 13:37:52 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 May 2019 13:37:52 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 2DBAFCBCB1 for ; Fri, 10 May 2019 13:37:47 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.001 X-Spam-Level: * X-Spam-Status: No, score=1.001 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id UEdFfcdll7fE for ; Fri, 10 May 2019 13:37:44 +0000 (UTC) Received: from internetallee.de (internetallee.de [81.169.162.220]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 9CC0F612C1 for ; Fri, 10 May 2019 13:37:44 +0000 (UTC) Received: from [192.168.122.94] (unknown [82.115.111.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by internetallee.de (Postfix) with ESMTPSA id 47F292C360AD7 for ; Fri, 10 May 2019 15:37:43 +0200 (CEST) Subject: Re: Want to get Integer value only from rational number To: user@jmeter.apache.org References: <005301d50627$0460ed90$0d22c8b0$@5nance.com> <2f856e5d-a1b6-fd5e-21be-84f03d414139@internetallee.de> <002201d50666$91d3def0$b57b9cd0$@5nance.com> <6128b9fc-2eb4-e58a-6f70-d961f4384d09@internetallee.de> <00bf01d5072d$c4d1e370$4e75aa50$@5nance.com> From: Felix Schumacher Message-ID: <309d8310-f5aa-ca99-453d-430807404993@internetallee.de> Date: Fri, 10 May 2019 15:37:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <00bf01d5072d$c4d1e370$4e75aa50$@5nance.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US Am 10.05.19 um 14:42 schrieb Shyam Panjiyar: > Thanks for Reply > > Resolved now good to know, but please don't mix ${varname} and JSR223 Samplers. The replacement of the variable to a String value will take place before the script is sent to the Sampler. This will work against the caching of the scripts, which is default now. The " ${var} + 0.5" in my first reply is meant to emulate rounding with the common round-up method. A value of "0.0" will do nothing and should be left out. The .toString() in your example is looking really strange, as it seems to imply that you are assigning a string value to an int variable. This is of course not the case as you are mixing ${...} with JSR 223 Samplers, which is -- I repeat -- not a good idea. If you insist on using a JSR 223 Sampler, use the tools that they provide:  int number = Math.round(Double.valueOf(vars.get('FinPlanIDGen'))).toInteger(); I gave the example with jexl3 function in case you wanted to convert the variable without a sampler or post-processor. Felix > > try > { > int number = ${__jexl3((${FinPlanIDGen} + 0.0 ).intValue().toString())}; > log.info("The converted integer is " + number); > vars.put("FinPlanIDGenerated", String.valueOf(number)); > } > catch (Exception ex){ > log.warn("Error in my script", ex); > throw ex; // elsewise JMeter will "swallow" the above exception > } > > Thanks & Regards, > Shyam Kishor Panjiyar > > -----Original Message----- > From: Shyam Panjiyar > Sent: 10 May 2019 16:24 > To: 'JMeter Users List' > Subject: Want to get Integer value only from rational number > > Hi , > > Could you please help with Bean Shell Sampler Script for below requirement :- > > Input - String sequence from JSON Extractor as 123.0 > > Output - String sequence in variable as 123 > > Thanks & Regards, > Shyam Panjiyar > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org > For additional commands, e-mail: user-help@jmeter.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org For additional commands, e-mail: user-help@jmeter.apache.org