コード例 #1
0
  private void executeAndCheckForOutputFile(
      final String executableName, final Executable executable, final List<String> failures)
      throws Exception {
    final File testOutputFile =
        File.createTempFile("schemacrawler." + executableName + ".", ".test");
    testOutputFile.delete();

    executable.getOutputOptions().setOutputFileName(testOutputFile.getAbsolutePath());
    executable.execute(testUtility.getConnection());

    failures.addAll(
        TestUtility.compareOutput(executableName + ".txt", testOutputFile, (OutputFormat) null));
  }
コード例 #2
0
 @Test
 public void testExecutables() throws Exception {
   final List<String> failures = new ArrayList<String>();
   for (final String beanDefinitionName : appContext.getBeanDefinitionNames()) {
     final Object bean = appContext.getBean(beanDefinitionName);
     if (bean instanceof Executable) {
       final Executable executable = (Executable) bean;
       if (!"graph".equals(executable.getCommand()) && !(executable instanceof GraphExecutable)) {
         executeAndCheckForOutputFile(beanDefinitionName, executable, failures);
       }
     }
   }
   if (failures.size() > 0) {
     fail(failures.toString());
   }
 }
コード例 #3
0
  @Test
  public void compareInfoLevelOutput() throws Exception {
    final List<String> failures = new ArrayList<String>();
    for (final InfoLevel infoLevel : InfoLevel.values()) {
      if (infoLevel == InfoLevel.unknown) {
        continue;
      }
      for (final SchemaTextDetailType schemaTextDetailType : SchemaTextDetailType.values()) {
        final String referenceFile = schemaTextDetailType + "_" + infoLevel + ".txt";

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

        final OutputOptions outputOptions =
            new OutputOptions(OutputFormat.text.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(infoLevel.getSchemaInfoLevel());

        final DatabaseConnectionOptions connectionOptions =
            testUtility.getDatabaseConnectionOptions();

        final Executable executable = new SchemaCrawlerExecutable(schemaTextDetailType.name());
        executable.setSchemaCrawlerOptions(schemaCrawlerOptions);
        executable.setOutputOptions(outputOptions);
        executable.execute(connectionOptions.getConnection());

        failures.addAll(
            TestUtility.compareOutput(
                INFO_LEVEL_OUTPUT + referenceFile,
                testOutputFile,
                outputOptions.getOutputFormat()));
      }
    }
    if (failures.size() > 0) {
      fail(failures.toString());
    }
  }
コード例 #4
0
 public void execute() throws Exception {
   final Executable executable = new SchemaCrawlerExecutable(command);
   if (outputOptions != null) {
     executable.setOutputOptions(outputOptions);
   }
   if (schemaCrawlerOptions != null) {
     executable.setSchemaCrawlerOptions(schemaCrawlerOptions);
   }
   if (config != null) {
     executable.setAdditionalConfiguration(config);
   }
   if (connectionOptions != null) {
     executable.execute(connectionOptions.createConnection());
   } else {
     throw new SchemaCrawlerException("No connection options provided");
   }
 }