@Test public void exportSingleLineWithUsernameAndPasswordFailsWhenReading() throws SQLException, IOException { final String username = "sa"; final String password = "pass"; final Path outputPath = Files.createTempFile("exportSingleLine", ".db"); final StoreLoader mockLoader = new MockDataLoader(singletonMap("HASH", "VALUE")); exporter.export(mockLoader, outputPath, username, password); final String connectionString = "jdbc:h2:" + outputPath; final Throwable throwable = catchThrowable(() -> DriverManager.getConnection(connectionString, null, null)); assertThat(throwable).isInstanceOf(JdbcSQLInvalidAuthorizationSpecException.class); }
@Override public void export(final StoreLoader loader, final Path output, final String username, final String password) throws SQLException, IOException { final String connectionString = "jdbc:h2:" + output.toString(); final List<String> createTableStatements = Stream.of(getClass().getResourceAsStream(CREATE_TABLE_RESOURCE)) .map(InputStreamReader::new) .map(BufferedReader::new) .flatMap(BufferedReader::lines) .collect(Collectors.toList()); final JdbcDataExporter jdbcDataExporter = new JdbcDataExporter(connectionString, INSERT_ROW, createTableStatements); jdbcDataExporter.export(loader, output, username, password); }
H2DataExporter implements DataExporter { @Override public void export(final StoreLoader loader, final Path output, final String username, final String password) throws SQLException, IOException { final String connectionString = "jdbc:h2:" + output.toString(); final List<String> createTableStatements = Stream.of(getClass().getResourceAsStream(CREATE_TABLE_RESOURCE)) .map(InputStreamReader::new) .map(BufferedReader::new) .flatMap(BufferedReader::lines) .collect(Collectors.toList()); final JdbcDataExporter jdbcDataExporter = new JdbcDataExporter(connectionString, INSERT_ROW, createTableStatements); jdbcDataExporter.export(loader, output, username, password); } }
H2DataExporter implements DataExporter { @Override public void export(final StoreLoader loader, final Path output, final String username, final String password) throws SQLException, IOException { final String connectionString = "jdbc:h2:" + output.toString(); final List<String> createTableStatements = Stream.of(getClass().getResourceAsStream(CREATE_TABLE_RESOURCE)) .map(InputStreamReader::new) .map(BufferedReader::new) .flatMap(BufferedReader::lines) .collect(Collectors.toList()); final JdbcDataExporter jdbcDataExporter = new JdbcDataExporter(connectionString, INSERT_ROW, createTableStatements); jdbcDataExporter.export(loader, output, username, password); }  }
H2DataExporter implements DataExporter { @Override public void export(final StoreLoader loader, final Path output, final String username, final String password) throws SQLException, IOException { final String connectionString = "jdbc:h2:" + output.toString(); final List<String> createTableStatements = Stream.of(getClass().getResourceAsStream(CREATE_TABLE_RESOURCE)) .map(InputStreamReader::new) .map(BufferedReader::new) .flatMap(BufferedReader::lines) .collect(Collectors.toList()); final JdbcDataExporter jdbcDataExporter = new JdbcDataExporter(connectionString, INSERT_ROW, createTableStatements); jdbcDataExporter.export(loader, output, username, password); }  @Override void export(final StoreLoader loader,
                       final Path output,
                       final String username,
                       final String password); }
H2DataExporter implements DataExporter { @Override public void export(final StoreLoader loader, final Path output, final String username, final String password) throws SQLException, IOException { final String connectionString = "jdbc:h2:" + output.toString(); final List<String> createTableStatements = Stream.of(getClass().getResourceAsStream(CREATE_TABLE_RESOURCE)) .map(InputStreamReader::new) .map(BufferedReader::new) .flatMap(BufferedReader::lines) .collect(Collectors.toList()); final JdbcDataExporter jdbcDataExporter = new JdbcDataExporter(connectionString, INSERT_ROW, createTableStatements); jdbcDataExporter.export(loader, output, username, password); }  @Override void export(final StoreLoader loader,
                       final Path output,
                       final String username,
                       final String password);  }