jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Memmesheimer, Christoph" <C.Memmeshei...@cenit.de>
Subject AW: How to pass Objects between Java Samplers
Date Wed, 20 Jan 2010 12:26:19 GMT
Hi,
well i want to test some EJBs and i want to share the JAAS Context for the Java Requests..
but i could not find an example which shows how to fill a jmeter variable from within a Java
Request (only how to push the jmeter vars as input parameter - with ${..}). 

Might it be correct that the most common way u can write values into jmeter variables is to
use beanshell scripts ?

Well I searched the Java API for myself and tried to use the static methods from JMeterContext
to create new JMeter Vars.. it works.. but it doesn't feel right :/ - is there a better way
? 

My Workaround:
_____________________________________
Java Request 1 (write Var)

org.apache.jmeter.threads.JMeterContext jmetercontext = org.apache.jmeter.threads.JMeterContextService.getContext();
JMeterVariables vars = jmetercontext.getVariables();
int a = new Integer(1);
vars.putObject("CODEVAR", a);
jmetercontext.setVariables(vars);

_____________________________________
Java Request 2 (read Var)

org.apache.jmeter.threads.JMeterContext jmetercontext = org.apache.jmeter.threads.JMeterContextService.getContext();
JMeterVariables vars = jmetercontext.getVariables();
	
Object a = vars.getObject("CODEVAR");
System.out.println("CODEVAR class:" + a.getClass().getName());
_____________________________________

-> tried to use CODEVAR as parameter for the Java Request 2 JavaSamplerContext (with ${CODEVAR}
in the GUI) but that doesn't work


@sebb: Should i use an other Sampler ? Thought this one would fit. 

Thanks & Regards,
Christoph

-----Urspr√ľngliche Nachricht-----
Von: sebb [mailto:sebbaz@gmail.com] 
Gesendet: Dienstag, 19. Januar 2010 17:59
An: JMeter Users List
Betreff: Re: How to pass Objects between Java Samplers

On 19/01/2010, Memmesheimer, Christoph <C.Memmesheimer@cenit.de> wrote:
> Hi,
>
>  i am new to JMeter.. is it possible to pass Java Objects between Java
>  Samplers ?
>
>  (thought about sharing a Connection Object)

Do you really mean Java Sampler as in:

http://jakarta.apache.org/jmeter/usermanual/component_reference.html#Java_Request

The provided Java samplers don't use Connection Objects.

I suggest you have a look at all the other samplers, and read the
manual a few times to get a better feel for what JMeter is about.

The standard way to pass items between samplers in the same thread is
to use a JMeter variable. These are normally Strings, but you can
store anything you like in them if you write the appropriate Java
code.

>
>  Thanks & Regards
>
>  Christoph
>
>
>
>  CENIT AG, Industriestrasse 52-54, 70565 Stuttgart, Tel.: +49 711 7825-30, Fax: +49 711
7825-4000, Internet: www.cenit.de
>  Geschaeftsstellen: Berlin, Duesseldorf, Frankfurt, Hamburg, Hannover, Muenchen, Oelsnitz,
Saarbruecken
>  Vorstandsmitglieder: Kurt Bengel, Christian Pusch
>  Aufsichtsratsmitglieder: Andreas Schmidt (Vorsitzender des Aufsichtsrats), Hubert Leypoldt,
Andreas Karrer
>  Bankverbindungen:
>  Deutsche Bank (BLZ 600 700 70) Kto. 1661 040 IBAN : DE85 6007 0070 0166 1040 00 SWIFT-CODE
: DEUTDESS,
>  Commerzbank (BLZ 600 400 71) Kto. 532 015 500 IBAN : DE83 6004 0071 0532 0155 00 SWIFT-Code
: COBADEFF600,
>  BW-Bank (BLZ 600 501 01) Kto. 2 403 313 IBAN : DE17 6005 0101 0002 4033 13 SWIFT-Code
: SOLADEST
>  Registergericht: Amtsgericht Stuttgart
>  Handelsregister: HRB Nr. 19117
>  Umsatzsteuer: ID-Nr. DE 147 862 777
>

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




CENIT AG, Industriestrasse 52-54, 70565 Stuttgart, Tel.: +49 711 7825-30, Fax: +49 711 7825-4000,
Internet: www.cenit.de
Geschaeftsstellen: Berlin, Duesseldorf, Frankfurt, Hamburg, Hannover, Muenchen, Oelsnitz,
Saarbruecken
Vorstandsmitglieder: Kurt Bengel, Christian Pusch
Aufsichtsratsmitglieder: Andreas Schmidt (Vorsitzender des Aufsichtsrats), Hubert Leypoldt,
Andreas Karrer
Bankverbindungen:
Deutsche Bank (BLZ 600 700 70) Kto. 1661 040 IBAN : DE85 6007 0070 0166 1040 00 SWIFT-CODE
: DEUTDESS,
Commerzbank (BLZ 600 400 71) Kto. 532 015 500 IBAN : DE83 6004 0071 0532 0155 00 SWIFT-Code
: COBADEFF600,
BW-Bank (BLZ 600 501 01) Kto. 2 403 313 IBAN : DE17 6005 0101 0002 4033 13 SWIFT-Code : SOLADEST
Registergericht: Amtsgericht Stuttgart
Handelsregister: HRB Nr. 19117
Umsatzsteuer: ID-Nr. DE 147 862 777


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


Mime
View raw message