@Test
  public void compareCompositeOutput() throws Exception {
    final String queryCommand1 = "all_tables";
    final Config queriesConfig = new Config();
    queriesConfig.put(queryCommand1, "SELECT * FROM INFORMATION_SCHEMA.SYSTEM_TABLES");
    final String queryCommand2 = "dump_tables";
    queriesConfig.put(
        queryCommand2, "SELECT ${orderbycolumns} FROM ${table} ORDER BY ${orderbycolumns}");

    final String[] commands =
        new String[] {
          SchemaTextDetailType.details + "," + Operation.count + "," + Operation.dump,
          SchemaTextDetailType.list + "," + Operation.count,
          queryCommand1
              + ","
              + queryCommand2
              + ","
              + Operation.count
              + ","
              + SchemaTextDetailType.list,
        };

    final List<String> failures = new ArrayList<String>();
    for (final OutputFormat outputFormat : OutputFormat.values()) {
      for (final String command : commands) {
        final String referenceFile = command + "." + outputFormat.name();

        final File testOutputFile =
            File.createTempFile("schemacrawler." + referenceFile + ".", ".test");
        testOutputFile.delete();

        final OutputOptions outputOptions = new OutputOptions(outputFormat.name(), testOutputFile);
        outputOptions.setNoInfo(false);
        outputOptions.setNoHeader(false);
        outputOptions.setNoFooter(false);

        final Config config =
            Config.load(
                SchemaCrawlerOutputTest.class.getResourceAsStream(
                    "/hsqldb.INFORMATION_SCHEMA.config.properties"));
        final SchemaCrawlerOptions schemaCrawlerOptions = new SchemaCrawlerOptions(config);
        schemaCrawlerOptions.setSchemaInfoLevel(SchemaInfoLevel.maximum());

        final DatabaseConnectionOptions connectionOptions =
            testUtility.getDatabaseConnectionOptions();

        final SchemaCrawlerExecutable executable = new SchemaCrawlerExecutable(command);
        executable.setSchemaCrawlerOptions(schemaCrawlerOptions);
        executable.setOutputOptions(outputOptions);
        executable.setAdditionalConfiguration(queriesConfig);
        executable.execute(connectionOptions.getConnection());

        failures.addAll(
            TestUtility.compareOutput(
                COMPOSITE_OUTPUT + referenceFile, testOutputFile, outputFormat));
      }
    }
    if (failures.size() > 0) {
      fail(failures.toString());
    }
  }
  @Test
  public void grep() throws Exception {
    clean(GREP_OUTPUT);

    final List<String> failures = new ArrayList<>();

    final String[][] grepArgs =
        new String[][] {
          new String[] {
            "-grepcolumns=.*\\.STREET|.*\\.PRICE", "-routines=",
          },
          new String[] {
            "-grepcolumns=.*\\..*NAME", "-routines=",
          },
          new String[] {
            "-grepdef=.*book authors.*", "-routines=",
          },
          new String[] {
            "-tables=", "-grepinout=.*\\.B_COUNT",
          },
          new String[] {
            "-tables=", "-grepinout=.*\\.B_OFFSET",
          },
          new String[] {
            "-grepcolumns=.*\\.STREET|.*\\.PRICE", "-grepdef=.*book authors.*", "-routines=",
          },
        };
    for (int i = 0; i < grepArgs.length; i++) {
      final String[] grepArgsForRun = grepArgs[i];

      final SchemaTextDetailType schemaTextDetailType = SchemaTextDetailType.details;
      final InfoLevel infoLevel = InfoLevel.detailed;
      final Path additionalProperties =
          createTempFile("hsqldb.INFORMATION_SCHEMA.config", "properties");
      final Writer writer =
          newBufferedWriter(
              additionalProperties, StandardCharsets.UTF_8, WRITE, CREATE, TRUNCATE_EXISTING);
      final Properties properties = new Properties();
      properties.load(
          this.getClass().getResourceAsStream("/hsqldb.INFORMATION_SCHEMA.config.properties"));
      properties.store(writer, this.getClass().getName());

      final String referenceFile = String.format("grep%02d.txt", i + 1);

      final Path testOutputFile = createTempFile(referenceFile, "data");

      final OutputFormat outputFormat = TextOutputFormat.text;

      final List<String> args =
          new ArrayList<>(
              Arrays.asList(
                  new String[] {
                    "-url=jdbc:hsqldb:hsql://localhost/schemacrawler",
                    "-user=sa",
                    "-password="******"-g=" + additionalProperties.toString(),
                    "-infolevel=" + infoLevel,
                    "-command=" + schemaTextDetailType,
                    "-outputformat=" + outputFormat.getFormat(),
                    "-outputfile=" + testOutputFile.toString(),
                    "-noinfo",
                  }));
      args.addAll(Arrays.asList(grepArgsForRun));

      Main.main(args.toArray(new String[args.size()]));

      failures.addAll(
          compareOutput(GREP_OUTPUT + referenceFile, testOutputFile, outputFormat.getFormat()));
    }

    if (failures.size() > 0) {
      fail(failures.toString());
    }
  }