7
7
import java .io .FileOutputStream ;
8
8
import java .io .IOException ;
9
9
import java .net .http .HttpResponse ;
10
- import java .nio .charset .StandardCharsets ;
11
10
import java .nio .file .Files ;
12
11
import java .nio .file .Path ;
13
12
import java .nio .file .Paths ;
65
64
import static oracle .weblogic .kubernetes .TestConstants .IMAGE_PULL_POLICY ;
66
65
import static oracle .weblogic .kubernetes .TestConstants .K8S_NODEPORT_HOST ;
67
66
import static oracle .weblogic .kubernetes .TestConstants .OKD ;
67
+ import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_12213 ;
68
68
import static oracle .weblogic .kubernetes .TestConstants .WEBLOGIC_IMAGE_TO_USE_IN_SPEC ;
69
69
import static oracle .weblogic .kubernetes .actions .ActionConstants .APP_DIR ;
70
70
import static oracle .weblogic .kubernetes .actions .ActionConstants .RESOURCE_DIR ;
95
95
import static oracle .weblogic .kubernetes .utils .DeployUtil .deployUsingWlst ;
96
96
import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainAndVerify ;
97
97
import static oracle .weblogic .kubernetes .utils .ExecCommand .exec ;
98
+ import static oracle .weblogic .kubernetes .utils .FileUtils .replaceStringInFile ;
98
99
import static oracle .weblogic .kubernetes .utils .ImageUtils .createBaseRepoSecret ;
99
100
import static oracle .weblogic .kubernetes .utils .JobUtils .createDomainJob ;
100
101
import static oracle .weblogic .kubernetes .utils .JobUtils .getIntrospectJobName ;
@@ -561,10 +562,13 @@ void testOnRestartOverride() {
561
562
//copy the template datasource file for override after replacing JDBC_URL with new datasource url
562
563
Path srcDsOverrideFile = Paths .get (RESOURCE_DIR , "configfiles/configoverridesset1/jdbc-JdbcTestDataSource-1.xml" );
563
564
Path dstDsOverrideFile = Paths .get (WORK_DIR , "jdbc-JdbcTestDataSource-1.xml" );
564
- String tempString = assertDoesNotThrow (()
565
- -> Files .readString (srcDsOverrideFile ).replaceAll ("JDBC_URL" , dsUrl2 ));
566
- assertDoesNotThrow (()
567
- -> Files .write (dstDsOverrideFile , tempString .getBytes (StandardCharsets .UTF_8 )));
565
+ assertDoesNotThrow (() -> {
566
+ Files .copy (srcDsOverrideFile , dstDsOverrideFile , StandardCopyOption .REPLACE_EXISTING );
567
+ replaceStringInFile (dstDsOverrideFile .toString (), "JDBC_URL" , dsUrl2 );
568
+ if (WEBLOGIC_12213 ) {
569
+ replaceStringInFile (dstDsOverrideFile .toString (), "com.mysql.cj.jdbc.Driver" , "com.mysql.jdbc.Driver" );
570
+ }
571
+ });
568
572
569
573
List <Path > overrideFiles = new ArrayList <>();
570
574
overrideFiles .add (dstDsOverrideFile );
@@ -1083,6 +1087,9 @@ private void createJdbcDataSource(String dsName, String user, String password,
1083
1087
logger .info ("hostAndPort = {0} " , hostAndPort );
1084
1088
String jdbcDsUrl = "jdbc:mysql://" + hostAndPort ;
1085
1089
1090
+ // based on WebLogic image, change the mysql driver to
1091
+ // 12.2.1.3 - com.mysql.jdbc.Driver
1092
+ // 12.2.1.4 and above - com.mysql.cj.jdbc.Driver
1086
1093
// create a temporary WebLogic domain property file
1087
1094
File domainPropertiesFile = File .createTempFile ("domain" , "properties" );
1088
1095
Properties p = new Properties ();
@@ -1092,7 +1099,11 @@ private void createJdbcDataSource(String dsName, String user, String password,
1092
1099
p .setProperty ("admin_password" , ADMIN_PASSWORD_DEFAULT );
1093
1100
p .setProperty ("dsName" , dsName );
1094
1101
p .setProperty ("dsUrl" , jdbcDsUrl );
1095
- p .setProperty ("dsDriver" , "com.mysql.cj.jdbc.Driver" );
1102
+ if (WEBLOGIC_12213 ) {
1103
+ p .setProperty ("dsDriver" , "com.mysql.jdbc.Driver" );
1104
+ } else {
1105
+ p .setProperty ("dsDriver" , "com.mysql.cj.jdbc.Driver" );
1106
+ }
1096
1107
p .setProperty ("dsUser" , user );
1097
1108
p .setProperty ("dsPassword" , password );
1098
1109
p .setProperty ("dsTarget" , clusterName );
0 commit comments