From 1ab0b3809efb34856961613a1f039593469ee996 Mon Sep 17 00:00:00 2001 From: Shriram Shri Shrikumar Date: Tue, 22 Jan 2013 15:57:03 +0000 Subject: [PATCH] Fix (hack) to prevent a ClassNotFoundException When Arquillian iterates through to figure out the observers, it has to iterate through each method in the class. When it does this, *IF* FacesContext cannot be resolved, it will error out with a ClassNotFoundException. The circumstances of this error are the tests within a JSF project that itself does not use JSF. For example, a test that initialises and uses JPA within a test project --- .../arquillian/mock_contexts/MockContextsManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/impl/src/main/java/pl/com/it_crowd/arquillian/mock_contexts/MockContextsManager.java b/impl/src/main/java/pl/com/it_crowd/arquillian/mock_contexts/MockContextsManager.java index f587752..ca8224a 100644 --- a/impl/src/main/java/pl/com/it_crowd/arquillian/mock_contexts/MockContextsManager.java +++ b/impl/src/main/java/pl/com/it_crowd/arquillian/mock_contexts/MockContextsManager.java @@ -30,8 +30,11 @@ public class MockContextsManager { // -------------------------- STATIC METHODS -------------------------- - private static void setFacesContextCurrentInstance(FacesContext mock) + private static void setFacesContextCurrentInstance(Object objMock) { + + FacesContext mock = (FacesContext) objMock; + try { Method setCurrentInstance = FacesContext.class.getDeclaredMethod("setCurrentInstance", FacesContext.class); setCurrentInstance.setAccessible(true);