Skip to content

Instantly share code, notes, and snippets.

@johnament
Last active October 11, 2015 21:05
Show Gist options
  • Save johnament/5a05b5c133b0bd7f4387 to your computer and use it in GitHub Desktop.
Save johnament/5a05b5c133b0bd7f4387 to your computer and use it in GitHub Desktop.
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