views:

323

answers:

1

I am using powermock 1.2.5 to perform a class that saves data into Oracle database. When I run my test my unit test fails with the following exception:

NoSuchAlgorithmException : DES Algorithm can be found.

After debugging the code I found out that this exception is thrown when my application is trying to set the password to establish a database connection.

Some of my observations are:

  1. If I run my unit test without power mock , then the exception does not occur.
  2. I manage to run the unit test if I manually include the sun-jce.jar file into the unit test bootstrap in eclipse.sun-jce.jar is one of the jar file within jre library folder. I am using SUN java jre version 1.5.0_10

So I am guessing that somehow power mock unloads this particular jar file during unit test runtime. Does any one encounter similiar problem when using powermock ?

A work around that I am thinking at the moment is to load the jar file programmatically under the setup() of my unit test.

A: 

Hi, Manage to resove this problem. It seems PowerMock loads its own crypto library. So if we add ignore the javax.crypto when we run power mock: @PowerMockIgnore({"javax.crypto" }), the test will work.

zfranciscus