Buggy code:
public class ArquillianService implements Service < ArquillianService > { public static final ServiceName SERVICE_NAME = JBOSS . append ( "arquillian" , "testrunner" ) ; private static final Logger log = Logger . getLogger ( "org.jboss.as.arquillian" ) ; private final InjectedValue < MBeanServer > injectedMBeanServer = new InjectedValue < MBeanServer > ( ) ; private final InjectedValue < ServerController > injectedServerController = new InjectedValue < ServerController > ( ) ; private final Map < String , ArquillianConfig > deployedTests = new HashMap < String , ArquillianConfig > ( ) ; private final Map < String , CountDownLatch > waitingTests = new HashMap < String , CountDownLatch > ( ) ; private JMXTestRunner jmxTestRunner ; public static void addService ( final ServiceTarget serviceTarget ) { } public static final String TEST_CLASS_PROPERTY = "org.jboss.as.arquillian.testClass" ; public synchronized void start ( StartContext context ) throws StartException { } public synchronized void stop ( StopContext context ) { } @ Override public ArquillianService getValue ( ) throws IllegalStateException { } void registerDeployment ( ArquillianConfig arqConfig ) { } void unregisterDeployment ( ArquillianConfig arqConfig ) { } private ArquillianConfig getConfig ( String className ) { } class TestClassLoaderImpl implements JMXTestRunner . TestClassLoader { private ServiceContainer serviceContainer ; private ServerDeploymentManager deploymentManager ; TestClassLoaderImpl ( ServiceContainer serviceContainer ) { } @ Override public Class < ? > loadTestClass ( String className ) throws ClassNotFoundException { ArquillianConfig arqConfig = getConfig ( className ) ; if ( arqConfig == null ) throw new ClassNotFoundException ( className ) ; if ( ( arqConfig . getTestClasses ( ) . contains ( className ) ) == false ) throw new ClassNotFoundException ( className ) ; DeploymentUnit depunit = arqConfig . getDeploymentUnitContext ( ) ; Module module = depunit . getAttachment ( MODULE ) ; Deployment osgidep = OSGiDeploymentAttachment . getDeployment ( depunit ) ; if ( ( module != null ) && ( osgidep != null ) ) throw new IllegalStateException ( ( "Found<seq2seq4repair_space>MODULE<seq2seq4repair_space>attachment<seq2seq4repair_space>for<seq2seq4repair_space>Bundle<seq2seq4repair_space>deployment:<seq2seq4repair_space>" + depunit ) ) ; Class < ? > testClass = null ; if ( module != null ) { ServiceContainerAssociation . setServiceContainer ( serviceContainer ) ; ServerDeploymentManagerAssociation . setServerDeploymentManager ( deploymentManager ) ; testClass = module . getClassLoader ( ) . loadClass ( className ) ; } else if ( osgidep != null ) { Bundle bundle = osgidep . getAttachment ( Bundle . class ) ; BundleAssociation . setBundle ( bundle ) ; ServiceContainerAssociation . setServiceContainer ( serviceContainer ) ; ServerDeploymentManagerAssociation . setServerDeploymentManager ( deploymentManager ) ; testClass = bundle . loadClass ( className ) ; } if ( testClass == null ) throw new ClassNotFoundException ( className ) ; if ( isOSGiSubsystemRequired ( testClass ) ) { ServiceController < ? > controller = serviceContainer . getRequiredService ( BundleContextService . SERVICE_NAME ) ; if ( ( controller . getState ( ) ) != ( State . UP ) ) { controller . setMode ( ACTIVE ) ; <START_BUG> assertServiceState ( BundleContextService . SERVICE_NAME , UP , 5000 ) ; <END_BUG> } BundleContextAssociation . setBundleContext ( ( ( BundleContext ) ( controller . getValue ( ) ) ) ) ; } return testClass ; } @ Override public ClassLoader getServiceClassLoader ( ) { } boolean isOSGiSubsystemRequired ( Class < ? > testClass ) { } void assertServiceState ( ServiceName serviceName , State expState , long timeout ) { } } }

Fix:
assertServiceState ( BundleContextService . SERVICE_NAME , UP , 10000 ) ;