1414public class PostgresOptions implements DBMSSpecificOptions <PostgresOracleFactory > {
1515 public static final String DEFAULT_HOST = "localhost" ;
1616 public static final int DEFAULT_PORT = 5432 ;
17- private static final boolean DEFAULT_TEST_TABLESPACES = determineDefaultTablespaceSupport () ;
17+ private static Boolean defaultTestTablespaces = null ;
1818
1919 @ Parameter (names = "--bulk-insert" , description = "Specifies whether INSERT statements should be issued in bulk" , arity = 1 )
2020 public boolean allowBulkInsert ;
@@ -26,7 +26,7 @@ public class PostgresOptions implements DBMSSpecificOptions<PostgresOracleFactor
2626 public boolean testCollations = true ;
2727
2828 @ Parameter (names = "--test-tablespaces" , description = "Specifies whether to test tablespace creation (default is OS-dependent)" , arity = 1 )
29- public boolean testTablespaces = DEFAULT_TEST_TABLESPACES ;
29+ public boolean testTablespaces = false ;
3030
3131 @ Parameter (names = "--tablespace-path" , description = "Base path for tablespace directories (default is OS-dependent)" , arity = 1 )
3232 public String tablespacePath = getDefaultTablespacePath ();
@@ -74,4 +74,46 @@ public static String getDefaultTablespacePath() {
7474 public List <PostgresOracleFactory > getTestOracleFactory () {
7575 return oracle ;
7676 }
77+
78+ public String getTablespacePath () {
79+ if (tablespacePath == null || tablespacePath .trim ().isEmpty ()) {
80+ throw new AssertionError ("Tablespace path is null or empty. Please configure --tablespace-path" );
81+ }
82+
83+ File path = new File (tablespacePath );
84+
85+ // Check if the directory exists or can be created
86+ if (!path .exists ()) {
87+ if (!path .mkdirs ()) {
88+ throw new AssertionError ("Cannot create tablespace directory: " + tablespacePath +
89+ ". Please ensure the parent directory exists and you have write permissions." );
90+ }
91+ }
92+
93+ // Check if it's actually a directory
94+ if (!path .isDirectory ()) {
95+ throw new AssertionError ("Tablespace path is not a directory: " + tablespacePath );
96+ }
97+
98+ // Check write permissions
99+ if (!path .canWrite ()) {
100+ throw new AssertionError ("No write permissions for tablespace directory: " + tablespacePath +
101+ ". Please ensure you have write permissions to this directory." );
102+ }
103+
104+ return tablespacePath ;
105+ }
106+
107+ public boolean isTestTablespaces () {
108+ // If the user explicitly set the value via command line, use that
109+ // Otherwise, use the OS-dependent default
110+ return testTablespaces || getDefaultTablespaceSupport ();
111+ }
112+
113+ private static boolean getDefaultTablespaceSupport () {
114+ if (defaultTestTablespaces == null ) {
115+ defaultTestTablespaces = determineDefaultTablespaceSupport ();
116+ }
117+ return defaultTestTablespaces ;
118+ }
77119}
0 commit comments