2020import io .cdap .plugin .OracleClient ;
2121import io .cucumber .java .After ;
2222import io .cucumber .java .Before ;
23+ import org .apache .commons .lang3 .RandomStringUtils ;
2324
2425import java .sql .SQLException ;
2526
2829 */
2930public class TestSetupHooks {
3031
31- @ Before (order = 1 , value = "@ORACLE_SOURCE_TEST" )
32- public static void setSelectQuery () {
33- String sourceTable = PluginPropertyUtils .pluginProp ("sourceTable" );
32+ @ Before (order = 1 )
33+ public static void setTableName () {
34+ String randomString = RandomStringUtils .randomAlphabetic (10 ).toUpperCase ();
35+ String sourceTableName = String .format ("SOURCETABLE_%s" , randomString );
36+ String targetTableName = String .format ("TARGETTABLE_%s" , randomString );
37+ PluginPropertyUtils .addPluginProp ("sourceTable" , sourceTableName );
38+ PluginPropertyUtils .addPluginProp ("targetTable" , targetTableName );
3439 String schema = PluginPropertyUtils .pluginProp ("schema" );
35- PluginPropertyUtils .addPluginProp ("selectQuery" ,
36- PluginPropertyUtils .pluginProp ("selectQuery" ).
37- replace ("${table}" , sourceTable ).replace ("${schema}" , schema ));
40+ PluginPropertyUtils .addPluginProp ("selectQuery" , String .format ("select * from %s.%s" , schema ,
41+ sourceTableName ));
3842 }
3943
4044 @ Before (order = 2 , value = "@ORACLE_SOURCE_TEST" )
@@ -45,15 +49,6 @@ public static void createTables() throws SQLException, ClassNotFoundException {
4549 PluginPropertyUtils .pluginProp ("schema" ));
4650 }
4751
48- @ Before (order = 1 , value = "@ORACLE_SOURCE_DATATYPES_TEST" )
49- public static void setSelectQueryForAllDatatypes () {
50- String sourceTable = PluginPropertyUtils .pluginProp ("sourceTable" );
51- String schema = PluginPropertyUtils .pluginProp ("schema" );
52- PluginPropertyUtils .addPluginProp ("selectQuery" ,
53- PluginPropertyUtils .pluginProp ("selectQuery" ).
54- replace ("${table}" , sourceTable ).replace ("${schema}" , schema ));
55- }
56-
5752 @ Before (order = 2 , value = "@ORACLE_SOURCE_DATATYPES_TEST" )
5853 public static void createAllDatatypesTables () throws SQLException , ClassNotFoundException {
5954 OracleClient .createSourceDatatypesTable (PluginPropertyUtils .pluginProp ("sourceTable" ),
@@ -62,15 +57,6 @@ public static void createAllDatatypesTables() throws SQLException, ClassNotFound
6257 PluginPropertyUtils .pluginProp ("schema" ));
6358 }
6459
65- @ Before (order = 1 , value = "@ORACLE_SOURCE_DATATYPES_TEST2" )
66- public static void setSelectQueryForLongDatatype () {
67- String sourceTable = PluginPropertyUtils .pluginProp ("sourceTable" );
68- String schema = PluginPropertyUtils .pluginProp ("schema" );
69- PluginPropertyUtils .addPluginProp ("selectQuery" ,
70- PluginPropertyUtils .pluginProp ("selectQuery" ).
71- replace ("${table}" , sourceTable ).replace ("${schema}" , schema ));
72- }
73-
7460 @ Before (order = 2 , value = "@ORACLE_SOURCE_DATATYPES_TEST2" )
7561 public static void createDatatypesTablesLong () throws SQLException , ClassNotFoundException {
7662 OracleClient .createSourceLongTable (PluginPropertyUtils .pluginProp ("sourceTable" ),
@@ -79,15 +65,6 @@ public static void createDatatypesTablesLong() throws SQLException, ClassNotFoun
7965 PluginPropertyUtils .pluginProp ("schema" ));
8066 }
8167
82- @ Before (order = 1 , value = "@ORACLE_SOURCE_LONGRAW_TEST" )
83- public static void setSelectQueryForDatatypesLongRaw () {
84- String sourceTable = PluginPropertyUtils .pluginProp ("sourceTable" );
85- String schema = PluginPropertyUtils .pluginProp ("schema" );
86- PluginPropertyUtils .addPluginProp ("selectQuery" ,
87- PluginPropertyUtils .pluginProp ("selectQuery" ).
88- replace ("${table}" , sourceTable ).replace ("${schema}" , schema ));
89- }
90-
9168 @ Before (order = 2 , value = "@ORACLE_SOURCE_LONGRAW_TEST" )
9269 public static void createDatatypesTablesLongRaw () throws SQLException , ClassNotFoundException {
9370 OracleClient .createSourceLongRawTable (PluginPropertyUtils .pluginProp ("sourceTable" ),
@@ -96,15 +73,6 @@ public static void createDatatypesTablesLongRaw() throws SQLException, ClassNotF
9673 PluginPropertyUtils .pluginProp ("schema" ));
9774 }
9875
99- @ Before (order = 1 , value = "@ORACLE_SOURCE_DATATYPES_TEST4" )
100- public static void setSelectQueryForLongVarchar () {
101- String sourceTable = PluginPropertyUtils .pluginProp ("sourceTable" );
102- String schema = PluginPropertyUtils .pluginProp ("schema" );
103- PluginPropertyUtils .addPluginProp ("selectQuery" ,
104- PluginPropertyUtils .pluginProp ("selectQuery" ).
105- replace ("${table}" , sourceTable ).replace ("${schema}" , schema ));
106- }
107-
10876 @ Before (order = 2 , value = "@ORACLE_SOURCE_DATATYPES_TEST4" )
10977 public static void createLongVarcharTables () throws SQLException , ClassNotFoundException {
11078 OracleClient .createSourceLongVarcharTable (PluginPropertyUtils .pluginProp ("sourceTable" ),
0 commit comments