From 388d8a8f9512c8e6659fef9028f2f8a7330985b9 Mon Sep 17 00:00:00 2001 From: Enrico Risa Date: Thu, 24 Aug 2023 14:51:33 +0200 Subject: [PATCH] chore(tests): removes TxPostgresqlLocalInstance --- .../helpers/TxPostgresqlLocalInstance.java | 82 ------------------- 1 file changed, 82 deletions(-) delete mode 100644 edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/helpers/TxPostgresqlLocalInstance.java diff --git a/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/helpers/TxPostgresqlLocalInstance.java b/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/helpers/TxPostgresqlLocalInstance.java deleted file mode 100644 index eaac4e0e2..000000000 --- a/edc-tests/e2e-tests/src/test/java/org/eclipse/tractusx/edc/helpers/TxPostgresqlLocalInstance.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2022 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - * - * Contributors: - * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation - * - */ - -package org.eclipse.tractusx.edc.helpers; - -import org.postgresql.ds.PGSimpleDataSource; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; -import javax.sql.DataSource; - -import static java.lang.String.format; - -@Deprecated(forRemoval = true) -public final class TxPostgresqlLocalInstance { - private final String password; - private final String jdbcUrlPrefix; - private final String username; - private final String databaseName; - - public TxPostgresqlLocalInstance(String user, String password, String jdbcUrlPrefix, String db) { - username = user; - this.password = password; - this.jdbcUrlPrefix = jdbcUrlPrefix; - databaseName = db; - } - - public void createDatabase() { - createDatabase(databaseName); - } - - public void createDatabase(String name) { - try (var connection = DriverManager.getConnection(jdbcUrlPrefix + username, username, password)) { - connection.createStatement().execute(format("create database %s;", name)); - } catch (SQLException e) { - e.printStackTrace(); - // database could already exist - } - } - - public Connection getTestConnection(String hostName, int port, String dbName) { - try { - return createTestDataSource(hostName, port, dbName).getConnection(); - } catch (SQLException e) { - throw new RuntimeException(e); - } - } - - public Connection getConnection() { - try { - return DriverManager.getConnection(jdbcUrlPrefix, username, password); - } catch (SQLException e) { - throw new RuntimeException(e); - } - } - - public String getJdbcUrlPrefix() { - return jdbcUrlPrefix; - } - - private DataSource createTestDataSource(String hostName, int port, String dbName) { - var dataSource = new PGSimpleDataSource(); - dataSource.setServerNames(new String[]{ hostName }); - dataSource.setPortNumbers(new int[]{ port }); - dataSource.setUser(username); - dataSource.setPassword(password); - dataSource.setDatabaseName(dbName); - return dataSource; - } -}