Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

powermock won't work with hadoop filesystem #455

Open
GoogleCodeExporter opened this issue Mar 24, 2015 · 3 comments
Open

powermock won't work with hadoop filesystem #455

GoogleCodeExporter opened this issue Mar 24, 2015 · 3 comments

Comments

@GoogleCodeExporter
Copy link

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

Attachments:

@GoogleCodeExporter
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant