Ejemplo n.º 1
0
  private ArquillianConfig getArquillianConfig(final String className, long timeout) {
    synchronized (deployedTests) {
      log.debugf("Getting Arquillian config for: %s", className);
      for (ArquillianConfig arqConfig : deployedTests) {
        for (String aux : arqConfig.getTestClasses()) {
          if (aux.equals(className)) {
            log.debugf("Found Arquillian config for: %s", className);
            return arqConfig;
          }
        }
      }

      if (timeout <= 0) {
        throw new IllegalStateException("Cannot obtain Arquillian config for: " + className);
      }

      try {
        log.debugf("Waiting on Arquillian config for: %s", className);
        deployedTests.wait(timeout);
      } catch (InterruptedException e) {
        // ignore
      }
    }
    return getArquillianConfig(className, -1);
  }
Ejemplo n.º 2
0
    @Override
    public Class<?> loadTestClass(final String className) throws ClassNotFoundException {

      final ArquillianConfig arqConfig = getArquillianConfig(className, -1);
      if (arqConfig == null)
        throw new ClassNotFoundException("No Arquillian config found for: " + className);

      // Make the BundleContext available to the {@link OSGiTestEnricher}
      BundleContext bundleContext = arqConfig.getBundleContext();
      BundleContextAssociation.setBundleContext(bundleContext);

      return arqConfig.loadClass(className);
    }
Ejemplo n.º 3
0
 void registerArquillianConfig(ArquillianConfig arqConfig) {
   synchronized (deployedTests) {
     log.debugf("Register Arquillian config: %s", arqConfig.getServiceName());
     deployedTests.add(arqConfig);
     deployedTests.notifyAll();
   }
 }
Ejemplo n.º 4
0
 private ContextManager initializeContextManager(
     final ArquillianConfig config, final Map<String, Object> properties) {
   final ContextManagerBuilder builder = new ContextManagerBuilder();
   final DeploymentUnit deployment = config.getDeploymentUnit();
   final Module module = deployment.getAttachment(Attachments.MODULE);
   if (module != null) {
     builder.add(new TCCLSetupAction(module.getClassLoader()));
   }
   builder.addAll(deployment);
   ContextManager contextManager = builder.build();
   contextManager.setup(properties);
   return contextManager;
 }
Ejemplo n.º 5
0
 void unregisterArquillianConfig(ArquillianConfig arqConfig) {
   synchronized (deployedTests) {
     log.debugf("Unregister Arquillian config: %s", arqConfig.getServiceName());
     deployedTests.remove(arqConfig);
   }
 }