public TestOutputStream() throws IOException { tempFile = IOUtility.createTempFilePath("test", ""); out = newOutputStream(tempFile, WRITE, CREATE, TRUNCATE_EXISTING); }
private Path createConfig(final Map<String, String> config) throws IOException { final String prefix = "SchemaCrawler.TestCommandLineConfig"; final Path configFile = IOUtility.createTempFilePath(prefix, "properties"); final Properties configProperties = new Properties(); configProperties.putAll(config); configProperties.store(newBufferedWriter(configFile, UTF_8), prefix); return configFile; }
@Override public Integer call() throws Exception { requireNonNull(command, "No command provided"); try { processOutput = createTempFilePath("scdot", "stdout"); processError = createTempFilePath("scdot", "stderr"); if (command.isEmpty()) { return null; } LOGGER.log(Level.CONFIG, new StringFormat("Executing:%n%s", command)); final ProcessBuilder processBuilder = new ProcessBuilder(command); processBuilder.redirectOutput(Redirect.appendTo(processOutput.toFile())); processBuilder.redirectOutput(Redirect.appendTo(processError.toFile())); final Process process = processBuilder.start(); exitCode = process.waitFor(); } catch (final Throwable t) { if (exitCode == 0) { exitCode = Integer.MIN_VALUE; } LOGGER.log(Level.SEVERE, t.getMessage(), t); } return exitCode; }
final Path finalHtmlFile = createTempFilePath("schemacrawler", "html"); final Path baseHtmlFile = createTempFilePath("schemacrawler", "html"); final Path baseSvgFile = createTempFilePath("schemacrawler", "svg");
private static Path writeToTempFile(final InputStream resourceStream) throws IOException, FileNotFoundException { final Path tempFile = IOUtility.createTempFilePath("resource", "data") .normalize().toAbsolutePath(); try (final OutputStream tempFileStream = newOutputStream(tempFile, WRITE, TRUNCATE_EXISTING, CREATE);) { fastChannelCopy(Channels.newChannel(resourceStream), Channels.newChannel(tempFileStream)); } return tempFile; }
private static Path writeConfigToTempFile(final Config config) throws IOException { if (config == null) { return null; } final Path tempFile = IOUtility.createTempFilePath("test", ".properties") .normalize().toAbsolutePath(); final Writer tempFileWriter = newBufferedWriter(tempFile, WRITE, TRUNCATE_EXISTING, CREATE); config.toProperties().store(tempFileWriter, "Store config to temporary file for testing"); return tempFile; }
@Test public void badEncoding() throws IOException { final String text = "Hello, World!"; final Path tempFilePath = IOUtility.createTempFilePath("test", ".dat"); Files.write(tempFilePath, text.getBytes("UTF-8")); final FileContents fileContents = new FileContents(tempFilePath, StandardCharsets.UTF_16); assertThat(fileContents.get(), is(not(text))); }
@Test public void happyPath() throws IOException { final String text = "Hello, World!"; final Path tempFilePath = IOUtility.createTempFilePath("test", ".dat"); Files.write(tempFilePath, text.getBytes("UTF-8")); final FileContents fileContents = new FileContents(tempFilePath); assertThat(fileContents.get(), is(text)); }
final InfoLevel infoLevel = InfoLevel.detailed; final Path additionalProperties = IOUtility .createTempFilePath("hsqldb.INFORMATION_SCHEMA.config", "properties"); final Writer writer = newBufferedWriter(additionalProperties, UTF_8, final Path testOutputFile = IOUtility.createTempFilePath(referenceFile, "data");
@Test public void nullcheck() throws IOException { assertThrows(NullPointerException.class, () -> new FileContents(null)); final Path tempFilePath = IOUtility.createTempFilePath("test", ".dat"); assertThrows(NullPointerException.class, () -> new FileContents(tempFilePath, null)); }
private Path createDiagram(final Connection connection, final String extension) throws Exception { checkConnection(connection); final SchemaCrawlerOptionsBuilder schemaCrawlerOptionsBuilder = SchemaCrawlerOptionsBuilder .builder().withSchemaInfoLevel(SchemaInfoLevelBuilder.standard()) .includeRoutines(new ExcludeAll()); final SchemaCrawlerOptions schemaCrawlerOptions = schemaCrawlerOptionsBuilder .toOptions(); final Path diagramFile = createTempFilePath("schemacrawler", extension); final OutputOptions outputOptions = OutputOptionsBuilder .newOutputOptions(extension, diagramFile); final SchemaCrawlerExecutable executable = new SchemaCrawlerExecutable("schema"); executable.setSchemaCrawlerOptions(schemaCrawlerOptions); executable.setOutputOptions(outputOptions); executable.setConnection(connection); executable.execute(); return diagramFile; }
@Override public Integer call() throws Exception { requireNonNull(command, "No command provided"); try { processOutput = createTempFilePath("scdot", "stdout"); processError = createTempFilePath("scdot", "stderr"); if (command.isEmpty()) { return null; } LOGGER.log(Level.CONFIG, new StringFormat("Executing:%n%s", command)); final ProcessBuilder processBuilder = new ProcessBuilder(command); processBuilder.redirectOutput(Redirect.appendTo(processOutput.toFile())); processBuilder.redirectOutput(Redirect.appendTo(processError.toFile())); final Process process = processBuilder.start(); exitCode = process.waitFor(); } catch (final Throwable t) { if (exitCode == 0) { exitCode = Integer.MIN_VALUE; } LOGGER.log(Level.SEVERE, t.getMessage(), t); } return exitCode; }
@Override public Integer call() throws Exception { requireNonNull(command, "No command provided"); try { processOutput = createTempFilePath("scdot", "stdout"); processError = createTempFilePath("scdot", "stderr"); if (command.isEmpty()) { return null; } LOGGER.log(Level.CONFIG, new StringFormat("Executing:%n%s", command)); final ProcessBuilder processBuilder = new ProcessBuilder(command); processBuilder.redirectOutput(Redirect.appendTo(processOutput.toFile())); processBuilder.redirectOutput(Redirect.appendTo(processError.toFile())); final Process process = processBuilder.start(); exitCode = process.waitFor(); } catch (final Throwable t) { if (exitCode == 0) { exitCode = Integer.MIN_VALUE; } LOGGER.log(Level.SEVERE, t.getMessage(), t); } return exitCode; }
final Path dotFile = createTempFilePath("schemacrawler.", "dot"); final OutputOptions dotFileOutputOptions; if (graphOutputFormat == GraphOutputFormat.scdot)
final Path finalHtmlFile = createTempFilePath("schemacrawler", "html"); final Path baseHtmlFile = createTempFilePath("schemacrawler", "html"); final Path baseSvgFile = createTempFilePath("schemacrawler", "svg");
final Path finalHtmlFile = createTempFilePath("schemacrawler", "html"); final Path baseHtmlFile = createTempFilePath("schemacrawler", "html"); final Path baseSvgFile = createTempFilePath("schemacrawler", "svg");
private Path createDiagram(final Connection connection, final String extension) throws Exception { checkConnection(connection); final SchemaCrawlerOptionsBuilder schemaCrawlerOptionsBuilder = SchemaCrawlerOptionsBuilder .builder().withSchemaInfoLevel(SchemaInfoLevelBuilder.standard()) .includeRoutines(new ExcludeAll()); final SchemaCrawlerOptions schemaCrawlerOptions = schemaCrawlerOptionsBuilder .toOptions(); final Path diagramFile = createTempFilePath("schemacrawler", extension); final OutputOptions outputOptions = OutputOptionsBuilder .newOutputOptions(extension, diagramFile); final SchemaCrawlerExecutable executable = new SchemaCrawlerExecutable("schema"); executable.setSchemaCrawlerOptions(schemaCrawlerOptions); executable.setOutputOptions(outputOptions); executable.setConnection(connection); executable.execute(); return diagramFile; }
private Path createDiagram(final Connection connection, final String extension) throws Exception { checkConnection(connection); final SchemaCrawlerOptionsBuilder schemaCrawlerOptionsBuilder = SchemaCrawlerOptionsBuilder .builder().withSchemaInfoLevel(SchemaInfoLevelBuilder.standard()) .includeRoutines(new ExcludeAll()); final SchemaCrawlerOptions schemaCrawlerOptions = schemaCrawlerOptionsBuilder .toOptions(); final Path diagramFile = createTempFilePath("schemacrawler", extension); final OutputOptions outputOptions = OutputOptionsBuilder .newOutputOptions(extension, diagramFile); final SchemaCrawlerExecutable executable = new SchemaCrawlerExecutable("schema"); executable.setSchemaCrawlerOptions(schemaCrawlerOptions); executable.setOutputOptions(outputOptions); executable.setConnection(connection); executable.execute(); return diagramFile; }
final Path dotFile = createTempFilePath("schemacrawler.", "dot"); final OutputOptions dotFileOutputOptions; if (graphOutputFormat == GraphOutputFormat.scdot)
final Path dotFile = createTempFilePath("schemacrawler.", "dot"); final OutputOptions dotFileOutputOptions; if (graphOutputFormat == GraphOutputFormat.scdot)