Example #1
0
  private int executeSingleCommand(Arguments arguments, FitNesseContext context) throws Exception {
    TestTextFormatter.finalErrorCount = 0;
    LOG.info("Executing command: " + arguments.getCommand());

    OutputStream os;

    boolean outputRedirectedToFile = arguments.getOutput() != null;

    if (outputRedirectedToFile) {
      LOG.info("-----Command Output redirected to " + arguments.getOutput() + "-----");
      os = new FileOutputStream(arguments.getOutput());
    } else {
      LOG.info("-----Command Output-----");
      os = System.out;
    }

    context.fitNesse.executeSingleCommand(arguments.getCommand(), os);
    context.fitNesse.stop();

    if (outputRedirectedToFile) {
      os.close();
    } else {
      LOG.info("-----Command Complete-----");
    }

    return TestTextFormatter.finalErrorCount;
  }
Example #2
0
 Integer launch(Arguments arguments, FitNesseContext context) throws Exception {
   if (!arguments.isInstallOnly()) {
     boolean started = context.fitNesse.start();
     if (started) {
       if (arguments.getCommand() != null) {
         return executeSingleCommand(arguments, context);
       }
     }
   }
   return null;
 }
Example #3
0
 /**
  * This is the main driver for recursively copying directories across file systems. It takes at
  * least two cmdline parameters. A source URL and a destination URL. It then essentially does an
  * "ls -lR" on the source URL, and writes the output in a round-robin manner to all the map input
  * files. The mapper actually copies the files allotted to it. The reduce is empty.
  */
 public int run(String[] args) {
   try {
     copy(conf, Arguments.valueOf(args, conf));
     return 0;
   } catch (IllegalArgumentException e) {
     System.err.println(StringUtils.stringifyException(e) + "\n" + usage);
     ToolRunner.printGenericCommandUsage(System.err);
     return -1;
   } catch (DuplicationException e) {
     System.err.println(StringUtils.stringifyException(e));
     return DuplicationException.ERROR_CODE;
   } catch (RemoteException e) {
     final IOException unwrapped =
         e.unwrapRemoteException(
             FileNotFoundException.class,
             AccessControlException.class,
             QuotaExceededException.class);
     System.err.println(StringUtils.stringifyException(unwrapped));
     return -3;
   } catch (Exception e) {
     System.err.println(
         "With failures, global counters are inaccurate; " + "consider running with -i");
     System.err.println("Copy failed: " + StringUtils.stringifyException(e));
     return -999;
   }
 }
Example #4
0
 boolean update(Arguments arguments, FitNesseContext context) throws IOException {
   if (!arguments.isOmittingUpdates()) {
     Updater updater = new UpdaterImplementation(context);
     return updater.update();
   }
   return false;
 }
Example #5
0
  public Integer launchFitNesse(Arguments arguments) throws Exception {
    configureLogging(arguments.hasVerboseLogging());
    loadPlugins();
    FitNesseContext context = loadContext(arguments);

    update(arguments, context);
    return launch(arguments, context);
  }
Example #6
0
  private FitNesseContext loadContext(Arguments arguments) throws Exception {
    Properties properties = loadConfigFile(arguments.getConfigFile());
    // Enrich properties with command line values:
    properties.setProperty(
        ComponentFactory.VERSIONS_CONTROLLER_DAYS,
        Integer.toString(arguments.getDaysTillVersionsExpire()));

    Builder builder = new Builder();
    ComponentFactory componentFactory = new ComponentFactory(properties);

    WikiPageFactory wikiPageFactory =
        (WikiPageFactory)
            componentFactory.createComponent(
                ComponentFactory.WIKI_PAGE_FACTORY_CLASS, FileSystemPageFactory.class);

    builder.properties = properties;
    builder.port = arguments.getPort();
    builder.rootPath = arguments.getRootPath();
    builder.rootDirectoryName = arguments.getRootDirectory();

    builder.versionsController =
        (VersionsController)
            componentFactory.createComponent(
                ComponentFactory.VERSIONS_CONTROLLER_CLASS, ZipFileVersionsController.class);
    builder.versionsController.setHistoryDepth(
        Integer.parseInt(properties.getProperty(ComponentFactory.VERSIONS_CONTROLLER_DAYS, "14")));
    builder.recentChanges =
        (RecentChanges)
            componentFactory.createComponent(
                ComponentFactory.RECENT_CHANGES_CLASS, RecentChangesWikiPage.class);

    builder.root = wikiPageFactory.makeRootPage(builder.rootPath, builder.rootDirectoryName);

    PluginsLoader pluginsLoader = new PluginsLoader(componentFactory);

    builder.logger = pluginsLoader.makeLogger(arguments.getLogDirectory());
    builder.authenticator = pluginsLoader.makeAuthenticator(arguments.getUserpass());

    FitNesseContext context = builder.createFitNesseContext();

    SymbolProvider symbolProvider = SymbolProvider.wikiParsingProvider;

    pluginsLoader.loadPlugins(context.responderFactory, symbolProvider);
    pluginsLoader.loadResponders(context.responderFactory);
    pluginsLoader.loadSymbolTypes(symbolProvider);
    pluginsLoader.loadContentFilter();
    pluginsLoader.loadSlimTables();
    pluginsLoader.loadCustomComparators();

    WikiImportTestEventListener.register();

    LOG.info("root page: " + context.root);
    LOG.info("logger: " + (context.logger == null ? "none" : context.logger.toString()));
    LOG.info("authenticator: " + context.authenticator);
    LOG.info("page factory: " + context.pageFactory);
    LOG.info("page theme: " + context.pageFactory.getTheme());
    LOG.info("Starting FitNesse on port: " + context.port);

    return context;
  }
Example #7
0
 // Move to Arguments class.
 public static Arguments parseCommandLine(String[] args) {
   CommandLine commandLine =
       new CommandLine(
           "[-v][-p port][-d dir][-r root][-l logDir][-f config][-e days][-o][-i][-a userpass][-c command][-b output]");
   Arguments arguments = null;
   if (commandLine.parse(args)) {
     arguments = new Arguments();
     if (commandLine.hasOption("v")) arguments.setVerboseLogging(true);
     if (commandLine.hasOption("p")) arguments.setPort(commandLine.getOptionArgument("p", "port"));
     if (commandLine.hasOption("d"))
       arguments.setRootPath(commandLine.getOptionArgument("d", "dir"));
     if (commandLine.hasOption("r"))
       arguments.setRootDirectory(commandLine.getOptionArgument("r", "root"));
     if (commandLine.hasOption("l"))
       arguments.setLogDirectory(commandLine.getOptionArgument("l", "logDir"));
     if (commandLine.hasOption("e"))
       arguments.setDaysTillVersionsExpire(commandLine.getOptionArgument("e", "days"));
     if (commandLine.hasOption("a"))
       arguments.setUserpass(commandLine.getOptionArgument("a", "userpass"));
     if (commandLine.hasOption("c"))
       arguments.setCommand(commandLine.getOptionArgument("c", "command"));
     if (commandLine.hasOption("b"))
       arguments.setOutput(commandLine.getOptionArgument("b", "output"));
     if (commandLine.hasOption("f"))
       arguments.setConfigFile(commandLine.getOptionArgument("f", "config"));
     arguments.setOmitUpdates(commandLine.hasOption("o"));
     arguments.setInstallOnly(commandLine.hasOption("i"));
   }
   return arguments;
 }