You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Oliver Wulff <ol...@zurich.ch> on 2008/02/07 15:00:46 UTC

JUnit sampler, read properties file

Hi there
I've set up a JUnit testcase and it runs fine. Now, I'd like to read
configuration data within the setUp method from a properties file. The
constructor string is used to pass the properties filename.
this.getClass().getClassLoader().getResourceAsStream("/config.properties");
//I also tried "config.properties"

I've added the directory of the properties file to the classpath
(jmeter.properties, user.classpath)
user.classpath=d:/prog/jmeter-2.3.1/lib/junit/etc

Unfortunately, the resource can't be found (InputStream is null).

Am I doing anything wrong here?

Thanks
Oliver






******************* BITTE BEACHTEN *******************
Diese Nachricht (wie auch allfällige Anhänge dazu) beinhaltet
möglicherweise vertrauliche oder gesetzlich geschützte Daten oder
Informationen. Zum Empfang derselben ist (sind) ausschliesslich die
genannte(n) Person(en) bestimmt. Falls Sie diese Nachricht
irrtümlicherweise erreicht hat, sind Sie höflich gebeten, diese unter
Ausschluss jeder Reproduktion zu zerstören und die absendende Person
umgehend zu benachrichtigen. Vielen Dank für Ihre Hilfe.


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


Antwort: Re: JUnit sampler, read properties file

Posted by Oliver Wulff <ol...@zurich.ch>.
Your code is independent from your installation location and directory
structure.



                                                                                                                                       
                      sebb                                                                                                             
                      <sebbaz@gmail.com        An:       "JMeter Users List" <jm...@jakarta.apache.org>                          
                      >                        Kopie:    (Blindkopie: Oliver Wulff/CHK/External/Zurich)                                
                                               Thema:    Re: JUnit sampler, read properties file                                       
                      08.02.2008 15:39                                                                                                 
                      Bitte antworten                                                                                                  
                      an "JMeter Users                                                                                                 
                      List"                                                                                                            
                                                                                                                                       




Why are you using the class loader? Can't you just load the properties
directly from the file?

On 07/02/2008, Oliver Wulff <ol...@zurich.ch> wrote:
>
> Hi there
> I've set up a JUnit testcase and it runs fine. Now, I'd like to read
> configuration data within the setUp method from a properties file. The
> constructor string is used to pass the properties filename.
>
this.getClass().getClassLoader().getResourceAsStream("/config.properties");
> //I also tried "config.properties"
>
> I've added the directory of the properties file to the classpath
> (jmeter.properties, user.classpath)
> user.classpath=d:/prog/jmeter-2.3.1/lib/junit/etc
>
> Unfortunately, the resource can't be found (InputStream is null).
>
> Am I doing anything wrong here?
>
> Thanks
> Oliver
>
>
>
>
>
>
> ******************* BITTE BEACHTEN *******************
> Diese Nachricht (wie auch allfällige Anhänge dazu) beinhaltet
> möglicherweise vertrauliche oder gesetzlich geschützte Daten oder
> Informationen. Zum Empfang derselben ist (sind) ausschliesslich die
> genannte(n) Person(en) bestimmt. Falls Sie diese Nachricht
> irrtümlicherweise erreicht hat, sind Sie höflich gebeten, diese unter
> Ausschluss jeder Reproduktion zu zerstören und die absendende Person
> umgehend zu benachrichtigen. Vielen Dank für Ihre Hilfe.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

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









******************* BITTE BEACHTEN *******************
Diese Nachricht (wie auch allfällige Anhänge dazu) beinhaltet
möglicherweise vertrauliche oder gesetzlich geschützte Daten oder
Informationen. Zum Empfang derselben ist (sind) ausschliesslich die
genannte(n) Person(en) bestimmt. Falls Sie diese Nachricht
irrtümlicherweise erreicht hat, sind Sie höflich gebeten, diese unter
Ausschluss jeder Reproduktion zu zerstören und die absendende Person
umgehend zu benachrichtigen. Vielen Dank für Ihre Hilfe.


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


Re: JUnit sampler, read properties file

Posted by sebb <se...@gmail.com>.
Why are you using the class loader? Can't you just load the properties
directly from the file?

On 07/02/2008, Oliver Wulff <ol...@zurich.ch> wrote:
>
> Hi there
> I've set up a JUnit testcase and it runs fine. Now, I'd like to read
> configuration data within the setUp method from a properties file. The
> constructor string is used to pass the properties filename.
> this.getClass().getClassLoader().getResourceAsStream("/config.properties");
> //I also tried "config.properties"
>
> I've added the directory of the properties file to the classpath
> (jmeter.properties, user.classpath)
> user.classpath=d:/prog/jmeter-2.3.1/lib/junit/etc
>
> Unfortunately, the resource can't be found (InputStream is null).
>
> Am I doing anything wrong here?
>
> Thanks
> Oliver
>
>
>
>
>
>
> ******************* BITTE BEACHTEN *******************
> Diese Nachricht (wie auch allfällige Anhänge dazu) beinhaltet
> möglicherweise vertrauliche oder gesetzlich geschützte Daten oder
> Informationen. Zum Empfang derselben ist (sind) ausschliesslich die
> genannte(n) Person(en) bestimmt. Falls Sie diese Nachricht
> irrtümlicherweise erreicht hat, sind Sie höflich gebeten, diese unter
> Ausschluss jeder Reproduktion zu zerstören und die absendende Person
> umgehend zu benachrichtigen. Vielen Dank für Ihre Hilfe.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

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