JiangYongGang / powermock

Automatically exported from code.google.com/p/powermock
Apache License 2.0
0 stars 0 forks source link

powermock won't work with hadoop filesystem #455

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.create any unit test with a setup() method, which create hadoop local file 
system
2.make dumb/empty test method, run the test make sure it pass
3.add @RunWith and @PrepareForTest at the top of the test

What is the expected output? What do you see instead?
test should still pass, but instead i got error message:
java.io.IOException: failure to login
    at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:490)
    at org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:452)
    at org.apache.hadoop.fs.FileSystem$Cache$Key.<init>(FileSystem.java:1494)
    at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:1395)
    at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:254)
    at org.apache.hadoop.fs.FileSystem.getLocal(FileSystem.java:225)

What version of the product are you using? On what operating system?
powermock-module-junit4  1.5.1
powermock-api-mockito     1.5.1
mockito-core                       1.9.5-rc1
Mac OS X                              10.8.4

Please provide any additional information below.
please see the attached sample code

Original issue reported on code.google.com by marsg...@gmail.com on 26 Aug 2013 at 6:11

GoogleCodeExporter commented 9 years ago
also found a url about a similar issue, not sure if it helps:
https://groups.google.com/a/cloudera.org/forum/#!msg/cdh-user/GpwgXf_tKv4/w6oZiB
Xb4McJ

Original comment by marsg...@gmail.com on 26 Aug 2013 at 6:20

GoogleCodeExporter commented 9 years ago
I had a similar issue. You can try telling PowerMock to defer the classloading 
of specific packages to the system classloader

I was only interested in having PowerMock mock my own packages, so I ignore the 
others like this:

@PowerMockIgnore({"javax.management*", "javax.xml.*", "org.w3c.*", 
"org.apache.apache.*", "com.sun.*"})

Original comment by t...@quixey.com on 12 Sep 2013 at 10:53

GoogleCodeExporter commented 9 years ago
Just tried this with Powermock 1.5.3 and the test passes for me.

Original comment by dmario...@gmail.com on 21 Jan 2014 at 9:42