コード例 #1
0
 private static JavaParameters checkCanRun(RunConfiguration configuration)
     throws ExecutionException {
   final RunProfileState state;
   state =
       ExecutionEnvironmentBuilder.create(
               DefaultRunExecutor.getRunExecutorInstance(), configuration)
           .build()
           .getState();
   assertNotNull(state);
   assertTrue(state instanceof JavaCommandLine);
   if (state instanceof TestPackage) {
     @SuppressWarnings("UnusedDeclaration")
     final JavaParameters parameters = ((TestPackage) state).getJavaParameters();
     final SearchForTestsTask task = ((TestPackage) state).createSearchingForTestsTask();
     assertNotNull(task);
     task.startSearch();
   }
   try {
     configuration.checkConfiguration();
   } catch (RuntimeConfigurationError e) {
     fail("cannot run: " + e.getMessage());
   } catch (RuntimeConfigurationException e) {
     // ignore
   }
   return ((JavaCommandLine) state).getJavaParameters();
 }
コード例 #2
0
  private void checkCantRun(RunConfiguration configuration, String reasonBeginning)
      throws ExecutionException {
    // MockRunRequest request = new MockRunRequest(myProject);
    // CantRunException rejectReason;
    // try {
    //  configuration.runRequested(request);
    //  rejectReason = request.myRejectReason;
    // }
    // catch (CantRunException e) {
    //  rejectReason = e;
    // }
    // if (rejectReason == null) fail("Should not run");
    // rejectReason.getMessage().startsWith(reasonBeginning);

    try {
      configuration.checkConfiguration();
    } catch (RuntimeConfigurationError e) {
      assertTrue(e.getLocalizedMessage().startsWith(reasonBeginning));
      return;
    } catch (RuntimeConfigurationException ignored) {

    }

    RunProfileState state =
        configuration.getState(
            DefaultRunExecutor.getRunExecutorInstance(),
            new ExecutionEnvironmentBuilder(myProject, DefaultRunExecutor.getRunExecutorInstance())
                .runProfile(configuration)
                .build());
    assertTrue(state instanceof JavaCommandLine);

    try {
      ((JavaCommandLine) state).getJavaParameters();
    } catch (Throwable e) {
      assertTrue(e.getLocalizedMessage().startsWith(reasonBeginning));
      return;
    }

    fail("Should not run");
  }