binary files not included in classpath for junit tests

Hi,

In a project, I have some crypto features that bundle their key along with the class. The project is built with ant and the key is properly bundled in the destination jar.

When I want to run the unit tests in the IDE however, the key cannot be found. The code does:

final ClassPathResource cpr = new ClassPathResource("com/foo/bar/keyfile");

...

final InputStream instr = cpr.getInputStream();

This throws an IOException because there is no "keyfile" in <project>/out/com/foo/bar/ as I would have expected.

How can I tell IntelliJ to include the keyfile in its classpath ?

Thanks.

2 comments
Comment actions Permalink

Hello Eric,

Settings | Compiler | Resource patterns

In a project, I have some crypto features that bundle their key along
with the class. The project is built with ant and the key is properly
bundled in the destination jar.

When I want to run the unit tests in the IDE however, the key cannot
be found. The code does:
final ClassPathResource cpr = new
ClassPathResource("com/foo/bar/keyfile");
..
final InputStream instr = cpr.getInputStream();
This throws an IOException because there is no "keyfile" in
<project>/out/com/foo/bar/ as I would have expected.

How can I tell IntelliJ to include the keyfile in its classpath ?

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Thanks a lot.

I should have looked at the compiler settings, I was only looking at the module details.

0

Please sign in to leave a comment.