You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Mick Knutson <mi...@gmail.com> on 2007/08/08 22:23:20 UTC

[m2] How to get access to test resources?

In my unit test, I have a call to get a test.txt file that live in
src/test/resources/test.txt

byte[] test = AES.file2byte("test.txt");

But it never finds the file....

Any help?

-- 

Thanks,
Mick Knutson

http://www.baselogic.com
http://www.blincmagazine.com
http://www.djmick.com
http://www.myspace.com/mickknutson
http://www.myspace.com/djmick_dot_com
http://www.myspace.com/sexybeotches
http://www.thumpradio.com
---

Re: [m2] How to get access to test resources?

Posted by Insitu <ab...@oqube.com>.
"Mick Knutson" <mi...@gmail.com> writes:

> In my unit test, I have a call to get a test.txt file that live in
> src/test/resources/test.txt
>
> byte[] test = AES.file2byte("test.txt");
>
> But it never finds the file....
>

You should access the file using classloader, as the resources are put
on your classpath:

  InputStream is = getClass().getResourceAsStream("/test.txt");

HTH

-- 
OQube < software engineering \ génie logiciel >
Arnaud Bailly, Dr.
\web> http://www.oqube.com


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org