Last active
October 11, 2015 21:05
-
-
Save johnament/5a05b5c133b0bd7f4387 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.jboss.arquillian.enablecdi; | |
import org.apache.deltaspike.cdise.api.CdiContainer; | |
import org.apache.deltaspike.cdise.api.CdiContainerLoader; | |
import org.apache.deltaspike.core.api.provider.BeanProvider; | |
import org.jboss.arquillian.junit.Arquillian; | |
import org.junit.runners.model.InitializationError; | |
import org.junit.runners.model.Statement; | |
/** | |
* Created by pestano on 11/10/15. | |
*/ | |
public class EnableCdiTestRunner extends Arquillian { | |
public EnableCdiTestRunner(Class<?> testClass) throws InitializationError { | |
super(testClass); | |
} | |
@Override | |
protected Object createTest() throws Exception { | |
Object ref = null; | |
try { | |
ref = BeanProvider.getContextualReference(getTestClass().getJavaClass(), true); | |
} catch (Exception e) { | |
// not in a container, not in a bean archive | |
} | |
if (ref == null){ | |
return super.createTeset(); | |
} | |
return ref; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment