Esempio n. 1
0
 @Override
 public Description getDescription() {
   Description description =
       Description.createSuiteDescription(getName(), fTestClass.getAnnotations());
   for (T child : getFilteredChildren()) description.addChild(describeChild(child));
   return description;
 }
  public InternalRemoteRunner(
      Class<?> testClass, String endpoint, Class<? extends Runner> remoteRunnerClass)
      throws InitializationError {
    super(testClass);
    this.testClass = testClass;
    this.remoteRunnerClass = remoteRunnerClass;
    TestClass tc = new TestClass(testClass);

    description = Description.createTestDescription(testClass, tc.getName(), tc.getAnnotations());

    for (FrameworkMethod method : tc.getAnnotatedMethods(Test.class)) {
      String methodName = method.getName();
      Description child =
          Description.createTestDescription(testClass, methodName, method.getAnnotations());

      methodNames.put(child, methodName);
      description.addChild(child);
    }

    if (executorService == null) {
      String ep = System.getProperty("junit.remote.endpoint");
      if (ep == null) {
        ep = endpoint;
      }

      for (String e : ep.split(",")) {
        if (e.trim().equals("")) {
          continue;
        }
        endpoints.add(e.trim());
      }
      executorService = Executors.newFixedThreadPool(endpoints.size());
    }

    setScheduler(
        new RunnerScheduler() {
          @Override
          public void schedule(final Runnable childStatement) {
            SEMAPHORE.reducePermits(1);
            executorService.submit(new SemaphoreDelegate(childStatement));
          }

          @Override
          public void finished() {
            try {
              SEMAPHORE.acquire();
              SEMAPHORE.release();
            } catch (InterruptedException ignore) {
              Thread.currentThread().interrupt();
            }
          }
        });
  }
Esempio n. 3
0
 /** @return the annotations that should be attached to this runner's description. */
 protected Annotation[] getRunnerAnnotations() {
   return fTestClass.getAnnotations();
 }