示例#1
0
 static void fail(@Nullable Object actualValue, Matcher<?> matcher) {
   Description description =
       new StringDescription()
           .appendText("\nExpected: ")
           .appendDescriptionOf(matcher)
           .appendText("\n     but: ");
   matcher.describeMismatch(actualValue, description);
   AssertionError assertionError = new AssertionError(description.toString());
   assertionError.setStackTrace(ObjectChecker.trimStackTrace(assertionError.getStackTrace()));
   throw assertionError;
 }
示例#2
0
  BARControl(String[] args) {
    try {
      // load settings
      Settings.load();

      // parse arguments
      parseArguments(args);

      // init display
      display = new Display();

      // connect to server
      LoginData loginData = new LoginData(serverName, serverPort, serverTLSPort);
      boolean connectOkFlag = false;
      if ((loginData.serverName != null)
          && !loginData.serverName.equals("")
          && (loginData.password != null)
          && !loginData.password.equals("")
          && !loginDialogFlag) {
        // connect to server with preset data
        try {
          BARServer.connect(
              loginData.serverName,
              loginData.port,
              loginData.tlsPort,
              loginData.password,
              serverKeyFileName);
          connectOkFlag = true;
        } catch (ConnectionError error) {
        }
      }
      while (!connectOkFlag) {
        // get login data
        if (!getLoginData(loginData)) {
          System.exit(0);
        }
        if ((loginData.port == 0) && (loginData.tlsPort == 0)) {
          throw new Error("Cannot connect to server. No server ports specified!");
        }
        /// ??? host name scheck

        // connect to server
        try {
          BARServer.connect(
              loginData.serverName,
              loginData.port,
              loginData.tlsPort,
              loginData.password,
              serverKeyFileName);
          connectOkFlag = true;
        } catch (ConnectionError error) {
          if (!Dialogs.confirmError(
              new Shell(),
              "Connection fail",
              "Error: " + error.getMessage(),
              "Try again",
              "Cancel")) {
            System.exit(1);
          }
        }
      }

      // open main window
      createWindow();
      createTabs();
      createMenu();

      // run
      run();

      // disconnect
      BARServer.disconnect();

      // save settings
      Settings.save();
    } catch (org.eclipse.swt.SWTException exception) {
      System.err.println("ERROR graphics: " + exception.getCause());
      if (debug) {
        for (StackTraceElement stackTraceElement : exception.getStackTrace()) {
          System.err.println("  " + stackTraceElement);
        }
      }
    } catch (CommunicationError communicationError) {
      System.err.println("ERROR communication: " + communicationError.getMessage());
    } catch (AssertionError assertionError) {
      System.err.println("INTERNAL ERROR: " + assertionError.toString());
      for (StackTraceElement stackTraceElement : assertionError.getStackTrace()) {
        System.err.println("  " + stackTraceElement);
      }
      System.err.println("");
      System.err.println("Please report this assertion error to [email protected].");
    } catch (InternalError error) {
      System.err.println("INTERNAL ERROR: " + error.getMessage());
    } catch (Error error) {
      System.err.println("ERROR: " + error.getMessage());
      if (debug) {
        for (StackTraceElement stackTraceElement : error.getStackTrace()) {
          System.err.println("  " + stackTraceElement);
        }
      }
    }
  }