diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1a3b4a11ce..2286721416 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: Java CI +name: Build 5.3.7 on: [push, pull_request, workflow_dispatch] @@ -22,7 +22,7 @@ jobs: - 1433:1433 options: --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P ${SA_PASSWORD} -Q 'SELECT 1' || exit 1" --health-interval 10s --health-timeout 5s --health-retries 5 steps: - - uses: szenius/set-timezone@v1.0 + - uses: szenius/set-timezone@v1.1 with: timezoneLinux: "UTC" - uses: actions/checkout@v2 @@ -32,13 +32,13 @@ jobs: java-version: '8' distribution: 'adopt' - name: Cache Lucee extensions - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/work/Lucee/Lucee/cache/ key: lucee-extensions restore-keys: lucee-extensions - name: Cache Maven packages - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.m2 key: ${{ runner.os }}-m2-${{ hashFiles('loader/pom.xml','core/pom.xml') }} @@ -47,7 +47,7 @@ jobs: maven-cache - name: Set up MySQL (local) run: | - sudo /etc/init.d/mysql start + sudo systemctl start mysql mysql -e 'CREATE DATABASE lucee' -uroot -proot mysql -e 'CREATE USER "lucee"@"localhost" IDENTIFIED WITH mysql_native_password BY "lucee";' -uroot -proot mysql -e 'GRANT ALL PRIVILEGES ON lucee.* TO "lucee"@"localhost"' -uroot -proot @@ -86,8 +86,10 @@ jobs: MSSQL_PORT: 1433 MSSQL_DATABASE: master S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_ID_TEST }} - S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY_TEST }} - DO_DEPLOY: ${{ github.event_name == 'push' }} + # s3 tests disabled due to LDEV-4474 + #S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY_TEST }} + S3_BUCKET_PREFIX: lucee-ldev-5- + # DO_DEPLOY: ${{ github.event_name == 'push' }} # for uploading successful builds S3_ACCESS_ID_DOWNLOAD: ${{ secrets.S3_ACCESS_ID_DOWNLOAD }} S3_SECRET_KEY_DOWNLOAD: ${{ secrets.S3_SECRET_KEY_DOWNLOAD }} @@ -95,6 +97,7 @@ jobs: CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} CI_DEPLOY_PASSPHRASE: ${{ secrets.CI_DEPLOY_PASSPHRASE }} + LUCEE_DOCKER_FILES_PAT_TOKEN: ${{ secrets.LUCEE_DOCKER_FILES_PAT_TOKEN }} #run: ant -noinput -buildfile loader/build.xml run: | if [ "${{ github.event_name == 'push' }}" == "true" ]; then @@ -104,8 +107,11 @@ jobs: echo "------- Maven Install on ${{ github.event_name }} ---------"; mvn -B -e -f loader/pom.xml clean install fi + - name: Remove Lucee build artifacts from local maven cache (avoid growing cache) + run: | + rm -rfv ~/.m2/repository/org/lucee/lucee/ - name: Publish Test Results - uses: EnricoMi/publish-unit-test-result-action@v1 + uses: EnricoMi/publish-unit-test-result-action@v2 if: always() with: files: test/reports/junit-test-results.xml diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..53584eac64 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "workbench.colorCustomizations": { + "activityBar.background": "#113425", + "titleBar.activeBackground": "#174834", + "titleBar.activeForeground": "#F4FBF8" + } +} \ No newline at end of file diff --git a/ant/build-core.xml b/ant/build-core.xml index 3b7cb43532..c38cd3b01b 100644 --- a/ant/build-core.xml +++ b/ant/build-core.xml @@ -1106,6 +1106,7 @@ + diff --git a/ant/run-testcases.xml b/ant/run-testcases.xml index ab08a6bc67..59c8b68479 100644 --- a/ant/run-testcases.xml +++ b/ant/run-testcases.xml @@ -109,6 +109,7 @@ function mem(type) { systemOutput("set /test mapping #dateTimeFormat(now())#", true); + setupTestServices = new test._setupTestServices().setup(); // set the testbox mapping application diff --git a/ant/upload-to-s3.xml b/ant/upload-to-s3.xml index b7654512c7..d02230ae18 100644 --- a/ant/upload-to-s3.xml +++ b/ant/upload-to-s3.xml @@ -1,5 +1,5 @@ - + @@ -17,128 +17,44 @@ diff --git a/ant/upload_to_s3.cfm b/ant/upload_to_s3.cfm new file mode 100644 index 0000000000..79dcc1883d --- /dev/null +++ b/ant/upload_to_s3.cfm @@ -0,0 +1,235 @@ + + // firstly, check are we even deploying to s3 + if ( (server.system.environment.DO_DEPLOY?:false) eq false ){ + SystemOutput( "skip, DO_DEPLOY is false", 1 ,1 ); + return; + } + // secondly, do we have the s3 extension? + s3ExtVersion = extensionList().filter( function(row){ return row.name contains "s3"; }).version; + if ( s3Extversion eq "" ){ + SystemOutput( "ERROR! The S3 Extension isn't installed!", true ); + return; + //throw "The S3 Extension isn't installed!"; // fatal + } else { + SystemOutput( "Using S3 Extension: #s3ExtVersion#", true ); + } + + // finally check for S3 credentials + if ( isNull( server.system.environment.S3_ACCESS_ID_DOWNLOAD ) + || isNull( server.system.environment.S3_SECRET_KEY_DOWNLOAD ) ) { + SystemOutput( "no S3 credentials defined to upload to S3", 1, 1 ); + return; + //throw "no S3 credentials defined to upload to S3"; + //trg.dir = ""; + } + + NL = " +"; + + src.jar = server.system.properties.luceejar; + src.core = server.system.properties.luceeCore; + src.dir = getDirectoryFromPath( src.jar ); + src.jarName = listLast( src.jar,"\/" ); + src.coreName = listLast( src.core,"\/" ); + src.version = mid( src.coreName,1,len( src.coreName )-4 ); + + if ( ! FileExists( src.jar ) || ! FileExists( src.core ) ){ + SystemOutput( src.jar & " exists: " & FileExists( src.jar ), true ); + SystemOutput( src.core & " exists: " & FileExists( src.core ), true ); + throw "missing jar or .lco file"; + } + + s3_bucket = "lucee-downloads"; + trg.dir = "s3://#server.system.environment.S3_ACCESS_ID_DOWNLOAD#:#server.system.environment.S3_SECRET_KEY_DOWNLOAD#@/#s3_bucket#/"; + + // test s3 access + SystemOutput( "Testing S3 Bucket Access", 1, 1 ); + if (! DirectoryExists( trg.dir ) ) + throw "DirectoryExists failed for s3 bucket [#s3_bucket#]"; // it usually will throw an error, rather than even reach this throw, if it fails + + trg.jar = trg.dir & src.jarName; + trg.core = trg.dir & src.coreName; + + // we only upload / publish artifacts once LDEV-3921 + + if ( fileExists( trg.jar ) && fileExists( trg.core ) ){ + SystemOutput( "Build artifacts have already been uploaded for this version, nothing to do", 1, 1 ); + return; + } + + function sendToS3 (name, path) { + var fh = fileOpen( path ); + s3write( bucketName=s3_bucket, + objectName=arguments.name, + value=fh, + accessKeyId=server.system.environment.S3_ACCESS_ID_DOWNLOAD, + secretAccessKey=server.system.environment.S3_SECRET_KEY_DOWNLOAD + ); + fileClose( fh ); + } + + // copy jar + SystemOutput( "upload #src.jarName# to S3",1,1 ); + if ( fileExists( trg.jar ) ){ + fileDelete( trg.jar ); + } + sendToS3( src.jarName, src.jar ); + + // copy core + SystemOutput( "upload #src.coreName# to S3",1,1 ); + if ( fileExists( trg.core ) ){ + fileDelete( trg.core ); + } + sendToS3( src.coreName, src.core ); + + // create war + src.warName = "lucee-" & src.version & ".war"; + src.war = src.dir & src.warName; + trg.war = trg.dir & src.warName; + + /* + SystemOutput( "upload #src.warName# to S3",1,1 ); + zip action = "zip" file = src.war overwrite = true { + + // loader + zipparam source = src.jar entrypath = "WEB-INF/lib/lucee.jar"; + + // common files + // zipparam source = commonDir; + + // website files + // zipparam source = webDir; + + // war files + // zipparam source = warDir; + } + fileCopy( src.war,trg.war ); + */ + + // Lucee light build (no extensions) + src.lightName = "lucee-light-" & src.version & ".jar"; + SystemOutput( "build and upload #src.lightName# to S3",1,1 ); + src.light = src.dir & src.lightName; + trg.light = trg.dir & src.lightName; + createLight( src.jar,src.light,src.version, false ); + + sendToS3( src.lightName, src.light ); + + // Lucee zero build, built from light but also no admin or docs (disabled, 6.0 only) + /* + src.zeroName = "lucee-zero-" & src.version & ".jar"; + SystemOutput( "build and upload #src.zeroName# to S3",1,1 ); + src.zero = src.dir & src.zeroName; + trg.zero = trg.dir & src.zeroName; + createLight( src.light, src.zero,src.version, true ); + fileCopy( src.zero, trg.zero ); + */ + // update provider + + systemOutput("Trigger builds", true); + http url="https://update.lucee.org/rest/update/provider/buildLatest" method="GET" timeout=90 result="buildLatest"; + systemOutput(buildLatest.fileContent, true); + + systemOutput("Update Extension Provider", true); + http url="https://extension.lucee.org/rest/extension/provider/reset" method="GET" timeout=90 result="extensionReset"; + systemOutput(extensionReset.fileContent, true); + + systemOutput("Update Downloads Page", true); + http url="https://download.lucee.org/?type=snapshots&reset=force" method="GET" timeout=90 result="downloadUpdate"; + systemOutput("Server response status code: " & downloadUpdate.statusCode, true); + + // forgebox + + systemOutput("Trigger forgebox builds", true); + + gha_pat_token = server.system.environment.LUCEE_DOCKER_FILES_PAT_TOKEN; // github person action token + body = { + "event_type": "forgebox_deploy" + }; + try { + http url="https://api.github.com/repos/Ortus-Lucee/forgebox-cfengine-publisher/dispatches" method="POST" result="result" timeout="90"{ + httpparam type="header" name='authorization' value='Bearer #gha_pat_token#'; + httpparam type="body" value='#body.toJson()#'; + + } + systemOutput("Forgebox build triggered, #result.statuscode# (always returns a 204 no content, see https://github.com/Ortus-Lucee/forgebox-cfengine-publisher/actions for output)", true); + } catch (e){ + systemOutput("Forgebox build ERRORED?", true); + echo(e); + } + + // Lucee Docker builds + + systemOutput("Trigger Lucee Docker builds", true); + + gha_pat_token = server.system.environment.LUCEE_DOCKER_FILES_PAT_TOKEN; // github person action token + body = { + "event_type": "build-docker-images", + "client_payload": { + "LUCEE_VERSION": server.system.properties.luceeVersion + } + }; + try { + http url="https://api.github.com/repos/lucee/lucee-dockerfiles/dispatches" method="POST" result="result" timeout="90"{ + httpparam type="header" name='authorization' value='Bearer #gha_pat_token#'; + httpparam type="body" value='#body.toJson()#'; + } + systemOutput("Lucee Docker builds triggered, #result.statuscode# (always returns a 204 no content, see https://github.com/lucee/lucee-dockerfiles/actions for output)", true); + } catch (e){ + systemOutput("Lucee Docker build ERRORED?", true); + echo(e); + } + + // express + + private function createLight( string loader, string trg, version, boolean noArchives=false ) { + var sep = server.separator.file; + var tmpDir = getTempDirectory(); + + local.tmpLoader = tmpDir & "lucee-loader-" & createUniqueId( ); // the jar + if ( directoryExists( tmpLoader ) ) + directoryDelete( tmpLoader,true ); + directoryCreate( tmpLoader ); + + // unzip + zip action = "unzip" file = loader destination = tmpLoader; + + // remove extensions + var extDir = tmpLoader&sep&"extensions"; + if ( directoryExists( extDir ) ) + directoryDelete( extDir, true ); // deletes directory with all files inside + directoryCreate( extDir ); // create empty dir again ( maybe Lucee expect this directory to exist ) + + // unzip core + var lcoFile = tmpLoader & sep & "core" & sep & "core.lco"; + local.tmpCore = tmpDir & "lucee-core-" & createUniqueId( ); // the jar + directoryCreate( tmpCore ); + zip action = "unzip" file = lcoFile destination = tmpCore; + + if (arguments.noArchives) { + // delete the lucee-admin.lar and lucee-docs.lar + var lightContext = tmpCore & sep & "resource/context" & sep; + loop list="lucee-admin.lar,lucee-doc.lar" item="local.larFile" { + fileDelete( lightContext & larFile ); + } + } + + // rewrite manifest + var manifest = tmpCore & sep & "META-INF" & sep & "MANIFEST.MF"; + var content = fileRead( manifest ); + var index = find( 'Require-Extension',content ); + if ( index > 0 ) + content = mid( content, 1, index - 1 ) & variables.NL; + fileWrite( manifest,content ); + + // zip core + fileDelete( lcoFile ); + zip action = "zip" source = tmpCore file = lcoFile; + + // zip loader + if ( fileExists( trg ) ) + fileDelete( trg ); + zip action = "zip" source = tmpLoader file = trg; + + } + \ No newline at end of file diff --git a/test/_setupTestServices.cfc b/test/_setupTestServices.cfc new file mode 100644 index 0000000000..a2b9ec3ba0 --- /dev/null +++ b/test/_setupTestServices.cfc @@ -0,0 +1,471 @@ +component { + /* + + rather than using env vars, you can define servers for testing here, just set a password etc + + note, a server configuration is only considered valid when all the requested properties have a value + empty strings are ignored, so the following configs will be ignored due to *_PASSWORD being empty + + i.e. a env.json + { + "MSSQL_PASSWORD": "top-secret", + "MYSQL_PASSWORD": "top-secret", + "POSTGRES_PASSWORD": "top-secret", + "MONGODB_PASSWORD": "top-secret", + "ORACLE_PASSWORD": "top-secret", + "FTP_PASSWORD": "top-secret", + "SFTP_PASSWORD": "top-secret", + "MAIL_PASSWORD": "top-secret", + "S3_SECRET_KEY": "top-secret" + } + + */ + + public function init (){ + if ( !server.keyExists( "test_services" ) ) + server.test_services = {}; + return this; + } + + public function setup () { + addSupportFunctions(); // puts functions into server scope so they can be accessed by all tests; + loadCustomBuildEnv(); + loadServiceConfig(); + } + + public void function loadCustomBuildEnv() localmode=true { + loadCustomEnvStubs(); + build_cfg = server._getSystemPropOrEnvVars( "LUCEE_BUILD_ENV", "", false ); + + if ( structKeyExists( build_cfg, "LUCEE_BUILD_ENV" ) ){ + env = build_cfg.LUCEE_BUILD_ENV; + if (!FileExists(env)){ + systemOutput( "ERROR: LUCEE_BUILD_ENV [#env#] file doesn't exist", true); + } else { + f = fileRead( env ); + if ( isJson( f ) ){ + structAppend( server.custom_build_env, deserializeJson( f ) ); + systemOutput( "IMPORTED: LUCEE_BUILD_ENV [#env#] configuation ", true ); + } else { + systemOutput( "ERROR: LUCEE_BUILD_ENV [#env#] wasn't json", true ); + } + + // hack! manually set up the variables, 6.0 handles this differently + var System = createObject("java", "java.lang.System"); + for ( var p in server.custom_build_env ){ + if ( len( server.custom_build_env[ p ] ) gt 0 ) // skip empty + System.setProperty( p, server.custom_build_env[ p ] ); + } + } + } + + } + + public function loadCustomEnvStubs(){ + server.custom_build_env = { + "MSSQL_SERVER": "127.0.0.1", + "MSSQL_USERNAME": "lucee", + "MSSQL_PASSWORD": "", // DON'T COMMIT + "MSSQL_PORT": 1433, + "MSSQL_DATABASE": "lucee", + + "MYSQL_SERVER": "localhost", + "MYSQL_USERNAME": "lucee", + "MYSQL_PASSWORD": "", // DON'T COMMIT + "MYSQL_PORT": 3306, + "MYSQL_DATABASE": "lucee", + + "POSTGRES_SERVER": "localhost", + "POSTGRES_USERNAME": "lucee", + "POSTGRES_PASSWORD": "", // DON'T COMMIT + "POSTGRES_PORT": 5432, + "POSTGRES_DATABASE": "lucee", + + "MONGODB_SERVER": "localhost", + "MONGODB_USERNAME": "", + "MONGODB_PASSWORD": "", // DON'T COMMIT + "MONGODB_PORT": 27017, + "MONGODB_DB": "lucee", + "MONGODB_DATABASE": "lucee", + /* + -- USER SQL + CREATE USER "C##LUCEE" INDENTIFIED BY "LUCEE" + ALTER USER "C##LUCEE" + DEFAULT TABLESPACE "USERS" + TEMPORARY TABLESPACE "TEMP" + ACCOUNT UNLOCK ; + + -- QUOTAS + ALTER USER "C##LUCEE" QUOTA UNLIMITED ON "USERS"; + + -- ROLES + ALTER USER "C##LUCEE" DEFAULT ROLE "CONNECT, RESOURCE"; + */ + "ORACLE_SERVER": "localhost", + "ORACLE_USERNAME": "c####lucee", + "ORACLE_PASSWORD": "", // DON'T COMMIT + "ORACLE_PORT": 1521, + "ORACLE_DATABASE": "XE", + + "FTP_SERVER": "localhost", + "FTP_USERNAME": "lucee", + "FTP_PASSWORD": "", // DON'T COMMIT + "FTP_PORT": 21, + "FTP_BASE_PATH": "/", + + "SFTP_SERVER"="localhost", + "SFTP_USERNAME": "lucee", + "SFTP_PASSWORD": "", // DON'T COMMIT + "SFTP_PORT": 990, + "SFTP_BASE_PATH": "/", + + "S3_ACCESS_KEY_ID": "test", + "S3_SECRET_KEY": "", + + "MAIL_USERNAME": "lucee", + "MAIL_PASSWORD": "", // DON'T COMMIT + + // imap, pop and smtp rely on MAIL_PASSWORD being defined + + "IMAP_SERVER": "localhost", + "IMAP_PORT_SECURE": 993, + "IMAP_PORT_INSECURE": 143, + + "POP_SERVER": "localhost", + "POP_PORT_SECURE": 995, + "POP_PORT_INSECURE": 110, + + "SMTP_SERVER": "localhost", + "SMTP_PORT_SECURE": 25, + "SMTP_PORT_INSECURE": 587 + }; + } + + public void function loadServiceConfig() localmode=true { + systemOutput( "", true) ; + systemOutput("-------------- Test Services ------------", true ); + + loop list="MySQL,MSsql,postgres,h2,oracle,mongoDb,smtp,pop,imap,s3,ftp,sftp" item="service" { + cfg = server.getTestService( service=service, verify=true ); + server.test_services[ service ]= { + valid: false, + missedTests: 0 + }; + if ( StructCount(cfg) eq 0 ){ + systemOutput( "Service [ #service# ] not configured", true) ; + } else { + // validate the cfg + verify = "configured, but not tested"; + try { + switch ( service ){ + case "s3": + verify = verifyS3(cfg); + break; + case "imap": + break; + case "pop": + break; + case "smtp": + break; + case "ftp": + verify = verifyFTP(cfg, service); + break; + case "sftp": + verify = verifyFTP(cfg, service); + break; + case "mongoDb": + verify = verifyMongo(cfg); + break; + default: + verify = verifyDatasource(cfg); + break; + } + systemOutput( "Service [ #service# ] is [ #verify# ]", true) ; + server.test_services[service].valid = true; + } catch (e) { + systemOutput( "ERROR Service [ #service# ] threw [ #cfcatch.message# ]", true); + } + } + } + systemOutput( " ", true); + } + + public array function reportServiceSkipped () localmode=true { + skipped = []; + for (s in server.test_services ){ + service = server.test_services[s]; + if ( !service.valid && service.missedTests gt 0 ){ + ArrayAppend( skipped, "-> Service [#s#] #chr(9)# not available, #chr(9)# #service.missedTests# tests skipped" ); + } + } + return skipped; + } + + public string function verifyDatasource ( struct datasource ) localmode=true{ + dbinfo type="Version" datasource="#arguments.datasource#" name="verify"; + dbDesc = []; + loop list="#verify.columnlist#" item="col" { + ArrayAppend( dbDesc, verify[ col ] ); + } + return ArrayToList( dbDesc, ", " ); + } + + public function verifyMongo ( mongo ) localmode=true { + conn = MongoDBConnect( arguments.mongo.db, arguments.mongo.server, arguments.mongo.port ); + /* + var q = extensionList().filter(function(row){ + return row.name contains "mongo"; + }); + */ + name = conn.command("buildInfo").version; // & ", " & q.name; + //conn.disconnect(); + return "MongoDB " & name; + } + + public function verifyFTP ( ftp, service ) localmode=true { + ftp action = "open" + connection = "conn" + timeout = 5 + secure= (arguments.service contains "sftp") + username = arguments.ftp.username + password = arguments.ftp.password + server = arguments.ftp.server + port= arguments.ftp.port; + + //ftp action = "close" connection = "conn"; + + return "Connection Verified"; + } + + public function verifyS3 ( s3 ) localmode=true{ + bucketName = arguments.s3.BUCKET_PREFIX & lcase(hash(CreateGUID())); + base = "s3://#arguments.s3.ACCESS_KEY_ID#:#arguments.s3.SECRET_KEY#@/#bucketName#"; + directoryCreate( base ); + directoryDelete( base ); + return "s3 Connection Verified [#bucketName#]"; + } + + + public function addSupportFunctions() { + server._getTempDir = function ( string prefix="" ) localmode=true{ + if ( len( arguments.prefix ) eq 0 ) { + local.dir = getTempDirectory() & "lucee-tests\" & createGUID(); + } else { + local.dir = getTempDirectory() & "lucee-tests\" & arguments.prefix; + } + if ( !directoryExists( dir ) ) + directoryCreate( dir, true ); + return dir; + }; + server._getSystemPropOrEnvVars = function ( string props="", string prefix="", boolean stripPrefix=true, boolean allowEmpty=false ) localmode=true{ + st = [=]; + keys = arguments.props.split( "," ); + n = arrayLen( keys ) ; + loop list="custom,environment,properties" item="src" { + if ( src eq "custom" ) + props = server.custom_build_env; // server.system is readonly + else + props = server.system[ src ]; + for (k in keys){ + k = prefix & trim( k ); + if ( !isNull( props[ k ] ) && Len( Trim( props[ k ] ) ) neq 0 ){ + kk = k; + if ( arguments.stripPrefix ) + kk = ListRest( k, "_" ); // return DATABASE for MSSQL_DATABASE + st[ kk ] = props[ k ]; + } + } + if ( structCount( st ) eq n ) + break; + else + st = {}; + } + if ( structCount( st ) eq n ){ + //systemOutput( st, true); + return st; // all or nothing + } else { + return {}; + } + }; + + // use this rather than all the boilerplate + server.getDatasource = getTestService; + server.getTestService = getTestService; + // TODO hmmmf closures and this scope! + server.getDefaultBundleVersion = getDefaultBundleVersion; + server.getBundleVersions = getBundleVersions; + } + public struct function getTestService( required string service, + string dbFile="", + boolean verify=false, + boolean onlyConfig=false + ) localmode=true { + if ( StructKeyExists( server.test_services, arguments.service ) ){ + if ( !server.test_services[ arguments.service ].valid ){ + //SystemOutput("Warning service: [ #arguments.service# ] is not available", true); + if ( !arguments.verify ) + server.test_services[ arguments.service ].missedTests++; + return {}; + } + } + + switch ( arguments.service ){ + case "mssql": + mssql = server._getSystemPropOrEnvVars( "SERVER, USERNAME, PASSWORD, PORT, DATABASE", "MSSQL_"); + if ( structCount( msSql ) gt 0){ + if ( arguments.onlyConfig ) + return msSql; + return { + class: 'com.microsoft.sqlserver.jdbc.SQLServerDriver' + , bundleName: 'org.lucee.mssql' + , bundleVersion: server.getDefaultBundleVersion('org.lucee.mssql', '4.0.2206.100') + , connectionString: 'jdbc:sqlserver://#msSQL.SERVER#:#msSQL.PORT#;DATABASENAME=#msSQL.DATABASE#;sendStringParametersAsUnicode=true;SelectMethod=direct' + , username: msSQL.username + , password: msSQL.password + }; + } + break; + case "mysql": + mysql = server._getSystemPropOrEnvVars( "SERVER, USERNAME, PASSWORD, PORT, DATABASE", "MYSQL_"); + if ( structCount( mySql ) gt 0 ){ + if ( arguments.onlyConfig ) + return mySql; + return { + class: 'com.mysql.cj.jdbc.Driver' + , bundleName: 'com.mysql.cj' + , bundleVersion: server.getDefaultBundleVersion('com.mysql.cj', '8.0.19') + , connectionString: 'jdbc:mysql://#mySQL.server#:#mySQL.port#/#mySQL.database#?useUnicode=true&characterEncoding=UTF-8&useLegacyDatetimeCode=true&useSSL=false' + , username: mySQL.username + , password: mySQL.password + }; + } + break; + case "postgres": + pgsql = server._getSystemPropOrEnvVars( "SERVER, USERNAME, PASSWORD, PORT, DATABASE", "POSTGRES_"); + if ( structCount( pgsql ) gt 0 ){ + if ( arguments.onlyConfig ) + return pgsql; + return { + class: 'org.postgresql.Driver' + , bundleName: 'org.postgresql.jdbc' + , bundleVersion: server.getDefaultBundleVersion('org.postgresql.jdbc', '42.2.20') + , connectionString: 'jdbc:postgresql://#pgsql.server#:#pgsql.port#/#pgsql.database#' + , username: pgsql.username + , password: pgsql.password + }; + } + break; + case "h2": + if ( arguments.verify ){ + tempDb = "#getTempDirectory()#/#createUUID()#"; + if (! DirectoryExists( tempDb ) ) + DirectoryCreate( tempDb ); + arguments.dbFile = tempDb; + } + if ( Len( arguments.dbFile ) ){ + return { + class: 'org.h2.Driver' + , bundleName: 'org.h2' + , bundleVersion: server.getDefaultBundleVersion('org.h2', '1.3.172') + , connectionString: 'jdbc:h2:#arguments.dbFile#/datasource/db;MODE=MySQL' + }; + } + break; + case "mongoDB": + mongoDB = server._getSystemPropOrEnvVars( "SERVER, PORT, DB", "MONGODB_"); + mongoDBcreds = server._getSystemPropOrEnvVars( "USERNAME, PASSWORD", "MONGODB_"); + if ( structCount( mongoDb ) gt 0 ){ + if (structCount( mongoDBcreds ) eq 2 ){ + StructAppend(mongoDB, mongoDBcreds) + } else { + // _getSystemPropOrEnvVars ignores empty variables + mongoDB.USERNAME=""; + mongoDB.PASSWORD=""; + } + return mongoDB; + } + break; + case "oracle": + oracle = server._getSystemPropOrEnvVars( "SERVER, USERNAME, PASSWORD, PORT, DATABASE", "ORACLE_"); + if ( structCount( oracle ) gt 0 ){ + if ( arguments.onlyConfig ) + return oracle; + return { + class: 'oracle.jdbc.OracleDriver' + , bundleName: 'ojdbc7' + , bundleVersion: server.getDefaultBundleVersion('ojdbc7', '11.2.0.4') + , connectionString: 'jdbc:oracle:thin:@#oracle.server#:#oracle.port#/#oracle.database#' + , username: oracle.username + , password: oracle.password + }; + } + break; + case "ftp": + ftp = server._getSystemPropOrEnvVars( "SERVER, USERNAME, PASSWORD, PORT, BASE_PATH", "FTP_"); + return ftp; + case "sftp": + sftp = server._getSystemPropOrEnvVars( "SERVER, USERNAME, PASSWORD, PORT, BASE_PATH", "SFTP_"); + return sftp; + case "mail": + mail = server._getSystemPropOrEnvVars( "USERNAME, PASSWORD", "MAIL_" ); + return mail; + case "smtp": + mail = server._getSystemPropOrEnvVars( "USERNAME, PASSWORD", "MAIL_" ); + if ( mail.count() gt 0 ){ + smtp = server._getSystemPropOrEnvVars( "SERVER, PORT_SECURE, PORT_INSECURE", "SMTP_" ); + return smtp; + } + break; + case "imap": + mail = server._getSystemPropOrEnvVars( "USERNAME, PASSWORD", "MAIL_" ); + if ( mail.count() gt 0 ){ + imap = server._getSystemPropOrEnvVars( "SERVER, PORT_SECURE, PORT_INSECURE", "IMAP_" ); + return imap; + } + break; + case "pop": + mail = server._getSystemPropOrEnvVars( "USERNAME, PASSWORD", "MAIL_" ); + if ( mail.count() gt 0 ){ + pop = server._getSystemPropOrEnvVars( "SERVER, PORT_SECURE, PORT_INSECURE", "POP_" ); + return pop; + } + break; + case "s3": + s3 = server._getSystemPropOrEnvVars( "ACCESS_KEY_ID, SECRET_KEY, BUCKET_PREFIX", "S3_" ); + return s3; + default: + break; + } + //SystemOutput( "", true); + SystemOutput( "Warning test service: [ #arguments.service# ] is not configured", true ); + return {}; + } + + function getDefaultBundleVersion (bundleName, fallbackVersion) cachedWithin="request" { + var bundles = server.getBundleVersions(); + if (structKeyExists(bundles, arguments.bundleName)){ + //systemOutput(arguments.bundleName & " " & bundles[arguments.bundleName], true) + return bundles[arguments.bundleName]; + } else { + systemOutput("getDefaultBundleVersion: [" & arguments.bundleName & "] FALLLING BACK TO DEFAULT [" & arguments.fallbackVersion & "]", true) + return arguments.fallbackVersion ; + } + } + + function getBundleVersions () cachedWithin="#createTimeSpan(1,0,0,0)#"{ + admin + type="server" + password="#server.SERVERADMINPASSWORD#" + action="getBundles" + returnvariable="q_bundles" + var bundles = {}; + loop query=q_bundles { + var _bundle = {}; + _bundle.append(q_bundles.headers); + bundles[_bundle['Bundle-SymbolicName']] = _bundle['Bundle-Version']; + } + return bundles; + } +} + + diff --git a/test/datasource/MySQL.cfc b/test/datasource/MySQL.cfc index 1bbfa4f693..011829b364 100644 --- a/test/datasource/MySQL.cfc +++ b/test/datasource/MySQL.cfc @@ -245,21 +245,13 @@ END private struct function getDatasource(){ var mySQL=getCredencials(); if(mySQL.count()==0) return {}; - - return { - class: 'org.gjt.mm.mysql.Driver' - , bundleName:'com.mysql.jdbc' - , bundleVersion:'5.1.38' - , connectionString: 'jdbc:mysql://'&mySQL.server&':'&mySQL.port&'/'&mySQL.database&'?useUnicode=true&characterEncoding=UTF-8&useLegacyDatetimeCode=true' - , username: mySQL.username - , password: mySQL.password - }; + return server.getDatasource("mysql"); } private struct function getDatasource2(){ var mySQL=getCredencials(); if(mySQL.count()==0) return {}; - + mysql = server.getDatasource(service="mysql", onlyConfig=true); return { type= 'mysql' , host=mySQL.server @@ -275,35 +267,7 @@ END } private struct function getCredencials() { - // getting the credetials from the enviroment variables - var mySQL={}; - if( - !isNull(server.system.environment.MYSQL_SERVER) && - !isNull(server.system.environment.MYSQL_USERNAME) && - !isNull(server.system.environment.MYSQL_PASSWORD) && - !isNull(server.system.environment.MYSQL_PORT) && - !isNull(server.system.environment.MYSQL_DATABASE)) { - mySQL.server=server.system.environment.MYSQL_SERVER; - mySQL.username=server.system.environment.MYSQL_USERNAME; - mySQL.password=server.system.environment.MYSQL_PASSWORD; - mySQL.port=server.system.environment.MYSQL_PORT; - mySQL.database=server.system.environment.MYSQL_DATABASE; - } - // getting the credetials from the system variables - else if( - !isNull(server.system.properties.MYSQL_SERVER) && - !isNull(server.system.properties.MYSQL_USERNAME) && - !isNull(server.system.properties.MYSQL_PASSWORD) && - !isNull(server.system.properties.MYSQL_PORT) && - !isNull(server.system.properties.MYSQL_DATABASE)) { - mySQL.server=server.system.properties.MYSQL_SERVER; - mySQL.username=server.system.properties.MYSQL_USERNAME; - mySQL.password=server.system.properties.MYSQL_PASSWORD; - mySQL.port=server.system.properties.MYSQL_PORT; - mySQL.database=server.system.properties.MYSQL_DATABASE; - } - - return mysql; + return server.getDatasource("mysql"); } diff --git a/test/datasource/PostgreSQL.cfc b/test/datasource/PostgreSQL.cfc index 684baf98c2..f5aca11942 100644 --- a/test/datasource/PostgreSQL.cfc +++ b/test/datasource/PostgreSQL.cfc @@ -28,13 +28,13 @@ component extends="org.lucee.cfml.test.LuceeTestCase" { public void function testConnection(){ _testConnection(defineDatasource()); } - public void function testConnection83(){ + public void function testConnection83() skip=true { // no longer works with postgres 14 on github actions _testConnection(defineDatasource83()); } - public void function testConnection94(){ + public void function testConnection94() skip=true { // no longer works with postgres 14 on github actions _testConnection(defineDatasource94()); } - public void function testConnection42(){ + public void function testConnection42() skip=true { // no longer works with postgres 14 on github actions _testConnection(defineDatasource42()); } private void function _testConnection(has){ @@ -146,44 +146,13 @@ component extends="org.lucee.cfml.test.LuceeTestCase" { var pgsql=getCredencials(); if(pgsql.count()==0) return false; application action="update" - datasource="#{ - class: 'org.postgresql.Driver' - , connectionString: 'jdbc:postgresql://#pgsql.server#:#pgsql.port#/#pgsql.database#' - , username: pgsql.username - , password: pgsql.password -}#"; + datasource="#server.getDatasource('postgres')#"; return true; } private struct function getCredencials() { // getting the credetials from the enviroment variables - var pgsql={}; - if( - !isNull(server.system.environment.POSTGRES_SERVER) && - !isNull(server.system.environment.POSTGRES_USERNAME) && - !isNull(server.system.environment.POSTGRES_PASSWORD) && - !isNull(server.system.environment.POSTGRES_PORT) && - !isNull(server.system.environment.POSTGRES_DATABASE)) { - pgsql.server=server.system.environment.POSTGRES_SERVER; - pgsql.username=server.system.environment.POSTGRES_USERNAME; - pgsql.password=server.system.environment.POSTGRES_PASSWORD; - pgsql.port=server.system.environment.POSTGRES_PORT; - pgsql.database=server.system.environment.POSTGRES_DATABASE; - } - // getting the credetials from the system variables - else if( - !isNull(server.system.properties.POSTGRES_SERVER) && - !isNull(server.system.properties.POSTGRES_USERNAME) && - !isNull(server.system.properties.POSTGRES_PASSWORD) && - !isNull(server.system.properties.POSTGRES_PORT) && - !isNull(server.system.properties.POSTGRES_DATABASE)) { - pgsql.server=server.system.properties.POSTGRES_SERVER; - pgsql.username=server.system.properties.POSTGRES_USERNAME; - pgsql.password=server.system.properties.POSTGRES_PASSWORD; - pgsql.port=server.system.properties.POSTGRES_PORT; - pgsql.database=server.system.properties.POSTGRES_DATABASE; - } - return pgsql; + return server.getDatasource("postgres"); } diff --git a/test/jira/Jira2049.cfc b/test/jira/Jira2049.cfc index 613d971c17..b6302b6dc6 100644 --- a/test/jira/Jira2049.cfc +++ b/test/jira/Jira2049.cfc @@ -59,24 +59,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase" { public boolean function notHasMySQLCredencials() { // getting the credetials from the enviroment variables - if( - !isNull(server.system.environment.MYSQL_SERVER) && - !isNull(server.system.environment.MYSQL_USERNAME) && - !isNull(server.system.environment.MYSQL_PASSWORD) && - !isNull(server.system.environment.MYSQL_PORT) && - !isNull(server.system.environment.MYSQL_DATABASE)) { - return false; - } - // getting the credetials from the system variables - else if( - !isNull(server.system.properties.MYSQL_SERVER) && - !isNull(server.system.properties.MYSQL_USERNAME) && - !isNull(server.system.properties.MYSQL_PASSWORD) && - !isNull(server.system.properties.MYSQL_PORT) && - !isNull(server.system.properties.MYSQL_DATABASE)) { - return false; - } - return true; + return !structIsEmpty(server.getDatasource("mysql")); } } diff --git a/test/jira/Jira2049/Application.cfc b/test/jira/Jira2049/Application.cfc index 01179180b6..b708969642 100755 --- a/test/jira/Jira2049/Application.cfc +++ b/test/jira/Jira2049/Application.cfc @@ -8,15 +8,7 @@ component { , connectionString: 'jdbc:h2:#getDirectoryFromPath(getCurrentTemplatePath())#/datasource/db;MODE=MySQL' };*/ - mySQL=getCredencials(); - this.datasource={ - class: 'org.gjt.mm.mysql.Driver' - , bundleName:'com.mysql.jdbc' - , bundleVersion:'5.1.38' - , connectionString: 'jdbc:mysql://'&mySQL.server&':'&mySQL.port&'/'&mySQL.database&'?useUnicode=true&characterEncoding=UTF-8&useLegacyDatetimeCode=true' - , username: mySQL.username - , password: mySQL.password - }; + this.datasource=server.getDatasource("mysql"); this.ormEnabled = true; this.ormSettings.flushatrequestend = false; @@ -29,34 +21,4 @@ component { ormReload(); } - private struct function getCredencials() { - // getting the credetials from the enviroment variables - var mySQL={}; - if( - !isNull(server.system.environment.MYSQL_SERVER) && - !isNull(server.system.environment.MYSQL_USERNAME) && - !isNull(server.system.environment.MYSQL_PASSWORD) && - !isNull(server.system.environment.MYSQL_PORT) && - !isNull(server.system.environment.MYSQL_DATABASE)) { - mySQL.server=server.system.environment.MYSQL_SERVER; - mySQL.username=server.system.environment.MYSQL_USERNAME; - mySQL.password=server.system.environment.MYSQL_PASSWORD; - mySQL.port=server.system.environment.MYSQL_PORT; - mySQL.database=server.system.environment.MYSQL_DATABASE; - } - // getting the credetials from the system variables - else if( - !isNull(server.system.properties.MYSQL_SERVER) && - !isNull(server.system.properties.MYSQL_USERNAME) && - !isNull(server.system.properties.MYSQL_PASSWORD) && - !isNull(server.system.properties.MYSQL_PORT) && - !isNull(server.system.properties.MYSQL_DATABASE)) { - mySQL.server=server.system.properties.MYSQL_SERVER; - mySQL.username=server.system.properties.MYSQL_USERNAME; - mySQL.password=server.system.properties.MYSQL_PASSWORD; - mySQL.port=server.system.properties.MYSQL_PORT; - mySQL.database=server.system.properties.MYSQL_DATABASE; - } - return mysql; - } } \ No newline at end of file diff --git a/test/jira/Jira2903.cfc b/test/jira/Jira2903.cfc index ce9da3547d..f80b42a732 100644 --- a/test/jira/Jira2903.cfc +++ b/test/jira/Jira2903.cfc @@ -32,14 +32,7 @@ var pgsql=getCredencials(); if(pgsql.count()==0) return false; application action="update" - datasource="#{ - class: 'org.postgresql.Driver' - , bundleName: 'org.postgresql.jdbc42' - , bundleVersion: '9.4.1212' - , connectionString: 'jdbc:postgresql://#pgsql.server#:#pgsql.port#/#pgsql.database#' - , username: pgsql.username - , password: pgsql.password -}#"; + datasource=pgsql; /* , bundleName: 'org.lucee.postgresql' , bundleVersion: '8.3.0.jdbc4' @@ -49,34 +42,7 @@ private struct function getCredencials() { - // getting the credetials from the enviroment variables - var pgsql={}; - if( - !isNull(server.system.environment.POSTGRES_SERVER) && - !isNull(server.system.environment.POSTGRES_USERNAME) && - !isNull(server.system.environment.POSTGRES_PASSWORD) && - !isNull(server.system.environment.POSTGRES_PORT) && - !isNull(server.system.environment.POSTGRES_DATABASE)) { - pgsql.server=server.system.environment.POSTGRES_SERVER; - pgsql.username=server.system.environment.POSTGRES_USERNAME; - pgsql.password=server.system.environment.POSTGRES_PASSWORD; - pgsql.port=server.system.environment.POSTGRES_PORT; - pgsql.database=server.system.environment.POSTGRES_DATABASE; - } - // getting the credetials from the system variables - else if( - !isNull(server.system.properties.POSTGRES_SERVER) && - !isNull(server.system.properties.POSTGRES_USERNAME) && - !isNull(server.system.properties.POSTGRES_PASSWORD) && - !isNull(server.system.properties.POSTGRES_PORT) && - !isNull(server.system.properties.POSTGRES_DATABASE)) { - pgsql.server=server.system.properties.POSTGRES_SERVER; - pgsql.username=server.system.properties.POSTGRES_USERNAME; - pgsql.password=server.system.properties.POSTGRES_PASSWORD; - pgsql.port=server.system.properties.POSTGRES_PORT; - pgsql.database=server.system.properties.POSTGRES_DATABASE; - } - return pgsql; + return server.getDatasource('postgres'); } diff --git a/test/jira/Jira3043.cfc b/test/jira/Jira3043.cfc index 567473a34e..f901dc91cc 100644 --- a/test/jira/Jira3043.cfc +++ b/test/jira/Jira3043.cfc @@ -64,47 +64,13 @@ component extends="org.lucee.cfml.test.LuceeTestCase" { var mySQL=getCredencials(); if(mySQL.count()==0) return false; application action="update" - datasource="# { - class: 'org.gjt.mm.mysql.Driver' - , bundleName:'com.mysql.jdbc' - , bundleVersion:'5.1.38' - , connectionString: 'jdbc:mysql://'&mySQL.server&':'&mySQL.port&'/'&mySQL.database&'?useUnicode=true&characterEncoding=UTF-8&useLegacyDatetimeCode=true' - , username: mySQL.username - , password: mySQL.password -}#"; + datasource="#mysql#"; - return true; + return true; } private struct function getCredencials() { - // getting the credetials from the enviroment variables - var mySQL={}; - if( - !isNull(server.system.environment.MYSQL_SERVER) && - !isNull(server.system.environment.MYSQL_USERNAME) && - !isNull(server.system.environment.MYSQL_PASSWORD) && - !isNull(server.system.environment.MYSQL_PORT) && - !isNull(server.system.environment.MYSQL_DATABASE)) { - mySQL.server=server.system.environment.MYSQL_SERVER; - mySQL.username=server.system.environment.MYSQL_USERNAME; - mySQL.password=server.system.environment.MYSQL_PASSWORD; - mySQL.port=server.system.environment.MYSQL_PORT; - mySQL.database=server.system.environment.MYSQL_DATABASE; - } - // getting the credetials from the system variables - else if( - !isNull(server.system.properties.MYSQL_SERVER) && - !isNull(server.system.properties.MYSQL_USERNAME) && - !isNull(server.system.properties.MYSQL_PASSWORD) && - !isNull(server.system.properties.MYSQL_PORT) && - !isNull(server.system.properties.MYSQL_DATABASE)) { - mySQL.server=server.system.properties.MYSQL_SERVER; - mySQL.username=server.system.properties.MYSQL_USERNAME; - mySQL.password=server.system.properties.MYSQL_PASSWORD; - mySQL.port=server.system.properties.MYSQL_PORT; - mySQL.database=server.system.properties.MYSQL_DATABASE; - } - return mysql; + return server.getDatasource("mysql"); } diff --git a/test/jira/Jira3074.cfc b/test/jira/Jira3074.cfc index 979ce3b8aa..dcc04867fd 100755 --- a/test/jira/Jira3074.cfc +++ b/test/jira/Jira3074.cfc @@ -11,47 +11,14 @@ var mySQL=getCredencials(); if(mySQL.count()==0) return false; application action="update" - datasource="# { - class: 'org.gjt.mm.mysql.Driver' - , bundleName:'com.mysql.jdbc' - , bundleVersion:'5.1.38' - , connectionString: 'jdbc:mysql://'&mySQL.server&':'&mySQL.port&'/'&mySQL.database&'?useUnicode=true&characterEncoding=UTF-8&useLegacyDatetimeCode=true' - , username: mySQL.username - , password: mySQL.password -}#"; + datasource="#mysql#"; return true; } private struct function getCredencials() { // getting the credetials from the enviroment variables - var mySQL={}; - if( - !isNull(server.system.environment.MYSQL_SERVER) && - !isNull(server.system.environment.MYSQL_USERNAME) && - !isNull(server.system.environment.MYSQL_PASSWORD) && - !isNull(server.system.environment.MYSQL_PORT) && - !isNull(server.system.environment.MYSQL_DATABASE)) { - mySQL.server=server.system.environment.MYSQL_SERVER; - mySQL.username=server.system.environment.MYSQL_USERNAME; - mySQL.password=server.system.environment.MYSQL_PASSWORD; - mySQL.port=server.system.environment.MYSQL_PORT; - mySQL.database=server.system.environment.MYSQL_DATABASE; - } - // getting the credetials from the system variables - else if( - !isNull(server.system.properties.MYSQL_SERVER) && - !isNull(server.system.properties.MYSQL_USERNAME) && - !isNull(server.system.properties.MYSQL_PASSWORD) && - !isNull(server.system.properties.MYSQL_PORT) && - !isNull(server.system.properties.MYSQL_DATABASE)) { - mySQL.server=server.system.properties.MYSQL_SERVER; - mySQL.username=server.system.properties.MYSQL_USERNAME; - mySQL.password=server.system.properties.MYSQL_PASSWORD; - mySQL.port=server.system.properties.MYSQL_PORT; - mySQL.database=server.system.properties.MYSQL_DATABASE; - } - return mysql; + return server.getDatasource("mysql") } public void function testCachedWithin(){ diff --git a/test/jira/Jira3157.cfc b/test/jira/Jira3157.cfc index ca0fcb3b9d..a75408e411 100644 --- a/test/jira/Jira3157.cfc +++ b/test/jira/Jira3157.cfc @@ -45,47 +45,13 @@ component extends="org.lucee.cfml.test.LuceeTestCase" { var mySQL=getCredencials(); if(mySQL.count()==0) return false; application action="update" - datasource="# { - class: 'org.gjt.mm.mysql.Driver' - , bundleName:'com.mysql.jdbc' - , bundleVersion:'5.1.38' - , connectionString: 'jdbc:mysql://'&mySQL.server&':'&mySQL.port&'/'&mySQL.database&'?useUnicode=true&characterEncoding=UTF-8&useLegacyDatetimeCode=true' - , username: mySQL.username - , password: mySQL.password -}#"; + datasource="#mysql#"; return true; } private struct function getCredencials() { - // getting the credetials from the enviroment variables - var mySQL={}; - if( - !isNull(server.system.environment.MYSQL_SERVER) && - !isNull(server.system.environment.MYSQL_USERNAME) && - !isNull(server.system.environment.MYSQL_PASSWORD) && - !isNull(server.system.environment.MYSQL_PORT) && - !isNull(server.system.environment.MYSQL_DATABASE)) { - mySQL.server=server.system.environment.MYSQL_SERVER; - mySQL.username=server.system.environment.MYSQL_USERNAME; - mySQL.password=server.system.environment.MYSQL_PASSWORD; - mySQL.port=server.system.environment.MYSQL_PORT; - mySQL.database=server.system.environment.MYSQL_DATABASE; - } - // getting the credetials from the system variables - else if( - !isNull(server.system.properties.MYSQL_SERVER) && - !isNull(server.system.properties.MYSQL_USERNAME) && - !isNull(server.system.properties.MYSQL_PASSWORD) && - !isNull(server.system.properties.MYSQL_PORT) && - !isNull(server.system.properties.MYSQL_DATABASE)) { - mySQL.server=server.system.properties.MYSQL_SERVER; - mySQL.username=server.system.properties.MYSQL_USERNAME; - mySQL.password=server.system.properties.MYSQL_PASSWORD; - mySQL.port=server.system.properties.MYSQL_PORT; - mySQL.database=server.system.properties.MYSQL_DATABASE; - } - return mysql; + return server.getDatasource("mysql"); } } \ No newline at end of file diff --git a/test/tags/Execute.cfc b/test/tags/Execute.cfc index 92bfe7c897..f3df1bd638 100644 --- a/test/tags/Execute.cfc +++ b/test/tags/Execute.cfc @@ -1,34 +1,35 @@ -component extends="org.lucee.cfml.test.LuceeTestCase" { + component extends="org.lucee.cfml.test.LuceeTestCase" { + + + //public function afterTests(){} + + public function setUp(){} + public function testName() { + cfexecute(name="curl https://update.lucee.org/rest/update/provider/echoGet" ,variable="local.x"); + assertTrue(find('"session"',x)>0); + } - //public function afterTests(){} - - public function setUp(){} - - public function testName() { - cfexecute(name="curl https://update.lucee.org/rest/update/provider/echoGet" ,variable="local.x"); - assertTrue(find('"session"',x)>0); - } - - public function testNameStringArg() { - cfexecute(name="curl", arguments="https://update.lucee.org/rest/update/provider/echoGet" ,variable="variables.x"); - assertTrue(find('"session"',x)>0); - } - - public function testNameStringArrayArg() { - cfexecute(name="curl", arguments=["https://update.lucee.org/rest/update/provider/echoGet"] ,variable="variables.x"); - assertTrue(find('"session"',x)>0); - } - - public function testTimeout() { - try { - cfexecute(name="curl", timeout="0.01", arguments="https://update.lucee.org/rest/update/provider/echoGet" ,variable="variables.x"); + public function testNameStringArg() { + cfexecute(name="curl", arguments="https://update.lucee.org/rest/update/provider/echoGet" ,variable="variables.x"); + assertTrue(find('"session"',x)>0); } - catch(e) { - assertTrue(find('expired',e.message)>0); + + public function testNameStringArrayArg() { + cfexecute(name="curl", arguments=["https://update.lucee.org/rest/update/provider/echoGet"] ,variable="variables.x"); + assertTrue(find('"session"',x)>0); } - } - -} - \ No newline at end of file + + + public function testTimeout() skip=true { + try { + cfexecute(name="curl", timeout="0.02", arguments="https://update.lucee.org/rest/update/provider/echoGet" ,variable="variables.x"); + } catch(e) { + expect(e.message).toInclude('expired', e.message); // this fails sometimes on CI + } + } + + } + + \ No newline at end of file diff --git a/test/tags/Http.cfc b/test/tags/Http.cfc index 6f4d74050d..08858445d1 100644 --- a/test/tags/Http.cfc +++ b/test/tags/Http.cfc @@ -36,7 +36,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase" { assertEquals("Sorglos",res.url.susi); } - public void function testImplicit(){ + public void function testImplicit() skip=true { var data=chr(228)&chr(246)&chr(252); // äöü data="{aaa:'#data#'}"; http url="https://update.lucee.org/rest/update/provider/echoPut" result="local.res" method="put" throwonerror="no" charset="utf-8"{ @@ -46,7 +46,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase" { assertEquals(data,res.httpRequestData.content); } - public void function testExplicit(){ + public void function testExplicit() skip=true { var data=chr(228)&chr(246)&chr(252); // äöü data="{aaa:'#data#'}"; http url="https://update.lucee.org/rest/update/provider/echoPut" result="local.res" method="put" throwonerror="no" charset="utf-8"{ diff --git a/test/tickets/LDEV0078.cfc b/test/tickets/LDEV0078.cfc index 2326641ced..92da8699ae 100644 --- a/test/tickets/LDEV0078.cfc +++ b/test/tickets/LDEV0078.cfc @@ -46,26 +46,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase" { } private boolean function hasCredencials() { - // getting the credetials from the enviroment variables - var mySQL={}; - if( - !isNull(server.system.environment.MYSQL_SERVER) && - !isNull(server.system.environment.MYSQL_USERNAME) && - !isNull(server.system.environment.MYSQL_PASSWORD) && - !isNull(server.system.environment.MYSQL_PORT) && - !isNull(server.system.environment.MYSQL_DATABASE)) { - return true; - } - // getting the credetials from the system variables - else if( - !isNull(server.system.properties.MYSQL_SERVER) && - !isNull(server.system.properties.MYSQL_USERNAME) && - !isNull(server.system.properties.MYSQL_PASSWORD) && - !isNull(server.system.properties.MYSQL_PORT) && - !isNull(server.system.properties.MYSQL_DATABASE)) { - return true; - } - return false; + return !structIsEmpty(server.getDatasource("mysql")); } } diff --git a/test/tickets/LDEV0078/Application.cfc b/test/tickets/LDEV0078/Application.cfc index c9a68dcbb6..499b5c2b80 100755 --- a/test/tickets/LDEV0078/Application.cfc +++ b/test/tickets/LDEV0078/Application.cfc @@ -6,14 +6,7 @@ component { mySQL=getCredencials(); - this.datasource ={ - class: 'org.gjt.mm.mysql.Driver' - , bundleName:'com.mysql.jdbc' - , bundleVersion:'5.1.38' - , connectionString: 'jdbc:mysql://'&mySQL.server&':'&mySQL.port&'/'&mySQL.database&'?useUnicode=true&characterEncoding=UTF-8&useLegacyDatetimeCode=true' - , username: mySQL.username - , password: mySQL.password - }; + this.datasource =mysql; @@ -48,34 +41,7 @@ component { private struct function getCredencials() { - // getting the credetials from the enviroment variables - var mySQL={}; - if( - !isNull(server.system.environment.MYSQL_SERVER) && - !isNull(server.system.environment.MYSQL_USERNAME) && - !isNull(server.system.environment.MYSQL_PASSWORD) && - !isNull(server.system.environment.MYSQL_PORT) && - !isNull(server.system.environment.MYSQL_DATABASE)) { - mySQL.server=server.system.environment.MYSQL_SERVER; - mySQL.username=server.system.environment.MYSQL_USERNAME; - mySQL.password=server.system.environment.MYSQL_PASSWORD; - mySQL.port=server.system.environment.MYSQL_PORT; - mySQL.database=server.system.environment.MYSQL_DATABASE; - } - // getting the credetials from the system variables - else if( - !isNull(server.system.properties.MYSQL_SERVER) && - !isNull(server.system.properties.MYSQL_USERNAME) && - !isNull(server.system.properties.MYSQL_PASSWORD) && - !isNull(server.system.properties.MYSQL_PORT) && - !isNull(server.system.properties.MYSQL_DATABASE)) { - mySQL.server=server.system.properties.MYSQL_SERVER; - mySQL.username=server.system.properties.MYSQL_USERNAME; - mySQL.password=server.system.properties.MYSQL_PASSWORD; - mySQL.port=server.system.properties.MYSQL_PORT; - mySQL.database=server.system.properties.MYSQL_DATABASE; - } - return mysql; + return server.getDatasource("mysql"); } diff --git a/test/tickets/LDEV0233.cfc b/test/tickets/LDEV0233.cfc index fed6ead09d..d5d47274f2 100644 --- a/test/tickets/LDEV0233.cfc +++ b/test/tickets/LDEV0233.cfc @@ -25,41 +25,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{ return baseURI & "" & calledName; } - private boolean function checkMySqlEnvVarsAvailable() { - // getting the credentials from the environment variables - var mySQL={}; - if(isNull(server.system)){ - server.system = structNew(); - currSystem = createObject("java", "java.lang.System"); - server.system.environment = currSystem.getenv(); - server.system.properties = currSystem.getproperties(); - } - - if( - !isNull(server.system.environment.MYSQL_SERVER) && - !isNull(server.system.environment.MYSQL_USERNAME) && - !isNull(server.system.environment.MYSQL_PASSWORD) && - !isNull(server.system.environment.MYSQL_PORT) && - !isNull(server.system.environment.MYSQL_DATABASE)) { - mySQL.server=server.system.environment.MYSQL_SERVER; - mySQL.username=server.system.environment.MYSQL_USERNAME; - mySQL.password=server.system.environment.MYSQL_PASSWORD; - mySQL.port=server.system.environment.MYSQL_PORT; - mySQL.database=server.system.environment.MYSQL_DATABASE; - } - // getting the credentials from the system variables - else if( - !isNull(server.system.properties.MYSQL_SERVER) && - !isNull(server.system.properties.MYSQL_USERNAME) && - !isNull(server.system.properties.MYSQL_PASSWORD) && - !isNull(server.system.properties.MYSQL_PORT) && - !isNull(server.system.properties.MYSQL_DATABASE)) { - mySQL.server=server.system.properties.MYSQL_SERVER; - mySQL.username=server.system.properties.MYSQL_USERNAME; - mySQL.password=server.system.properties.MYSQL_PASSWORD; - mySQL.port=server.system.properties.MYSQL_PORT; - mySQL.database=server.system.properties.MYSQL_DATABASE; - } - return structIsEmpty(mySQL); + private boolean function checkMySqlEnvVarsAvailable() { + return structIsEmpty(server.getDatasource("mysql")); } } \ No newline at end of file diff --git a/test/tickets/LDEV0233/Application.cfc b/test/tickets/LDEV0233/Application.cfc index 13a3193501..c7b67a8dff 100644 --- a/test/tickets/LDEV0233/Application.cfc +++ b/test/tickets/LDEV0233/Application.cfc @@ -6,14 +6,7 @@ component output="false" { mySQL = getCredentials(); this.ormenabled = true; - this.datasources["trans"] = { - class: 'org.gjt.mm.mysql.Driver' - , bundleName:'com.mysql.jdbc' - , bundleVersion:'5.1.38' - , connectionString: 'jdbc:mysql://'&mySQL.server&':'&mySQL.port&'/'&mySQL.database&'?useUnicode=true&characterEncoding=UTF-8&useLegacyDatetimeCode=true' - , username: mySQL.username - , password: mySQL.password - }; + this.datasources["trans"] = mysql; this.ormsettings={datasource="trans" ,logsql="false" ,cfclocation="model" @@ -33,41 +26,7 @@ component output="false" { // Private function to get dsn details from env vars private struct function getCredentials() { - // getting the credentials from the environment variables - var mySQL={}; - if(isNull(server.system)){ - server.system = structNew(); - currSystem = createObject("java", "java.lang.System"); - server.system.environment = currSystem.getenv(); - server.system.properties = currSystem.getproperties(); - } - - if( - !isNull(server.system.environment.MYSQL_SERVER) && - !isNull(server.system.environment.MYSQL_USERNAME) && - !isNull(server.system.environment.MYSQL_PASSWORD) && - !isNull(server.system.environment.MYSQL_PORT) && - !isNull(server.system.environment.MYSQL_DATABASE)) { - mySQL.server=server.system.environment.MYSQL_SERVER; - mySQL.username=server.system.environment.MYSQL_USERNAME; - mySQL.password=server.system.environment.MYSQL_PASSWORD; - mySQL.port=server.system.environment.MYSQL_PORT; - mySQL.database=server.system.environment.MYSQL_DATABASE; - } - // getting the credentials from the system variables - else if( - !isNull(server.system.properties.MYSQL_SERVER) && - !isNull(server.system.properties.MYSQL_USERNAME) && - !isNull(server.system.properties.MYSQL_PASSWORD) && - !isNull(server.system.properties.MYSQL_PORT) && - !isNull(server.system.properties.MYSQL_DATABASE)) { - mySQL.server=server.system.properties.MYSQL_SERVER; - mySQL.username=server.system.properties.MYSQL_USERNAME; - mySQL.password=server.system.properties.MYSQL_PASSWORD; - mySQL.port=server.system.properties.MYSQL_PORT; - mySQL.database=server.system.properties.MYSQL_DATABASE; - } - return mysql; + return server.getDatasource("mysql"); } } diff --git a/test/tickets/LDEV0563.cfc b/test/tickets/LDEV0563.cfc index ed89a97d26..90fc20ce9a 100644 --- a/test/tickets/LDEV0563.cfc +++ b/test/tickets/LDEV0563.cfc @@ -83,39 +83,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{ private boolean function checkMySqlEnvVarsAvailable() { // getting the credentials from the environment variables - var mySQL={}; - if(isNull(server.system)){ - server.system = structNew(); - currSystem = createObject("java", "java.lang.System"); - server.system.environment = currSystem.getenv(); - server.system.properties = currSystem.getproperties(); - } - - if( - !isNull(server.system.environment.MYSQL_SERVER) && - !isNull(server.system.environment.MYSQL_USERNAME) && - !isNull(server.system.environment.MYSQL_PASSWORD) && - !isNull(server.system.environment.MYSQL_PORT) && - !isNull(server.system.environment.MYSQL_DATABASE)) { - mySQL.server=server.system.environment.MYSQL_SERVER; - mySQL.username=server.system.environment.MYSQL_USERNAME; - mySQL.password=server.system.environment.MYSQL_PASSWORD; - mySQL.port=server.system.environment.MYSQL_PORT; - mySQL.database=server.system.environment.MYSQL_DATABASE; - } - // getting the credentials from the system variables - else if( - !isNull(server.system.properties.MYSQL_SERVER) && - !isNull(server.system.properties.MYSQL_USERNAME) && - !isNull(server.system.properties.MYSQL_PASSWORD) && - !isNull(server.system.properties.MYSQL_PORT) && - !isNull(server.system.properties.MYSQL_DATABASE)) { - mySQL.server=server.system.properties.MYSQL_SERVER; - mySQL.username=server.system.properties.MYSQL_USERNAME; - mySQL.password=server.system.properties.MYSQL_PASSWORD; - mySQL.port=server.system.properties.MYSQL_PORT; - mySQL.database=server.system.properties.MYSQL_DATABASE; - } + var mySQL=server.getDatasource("mysql"); return structIsEmpty(mySQL); } } \ No newline at end of file diff --git a/test/tickets/LDEV0563/mysql/Application.cfc b/test/tickets/LDEV0563/mysql/Application.cfc index 98f7c5b0b8..292e5c98da 100644 --- a/test/tickets/LDEV0563/mysql/Application.cfc +++ b/test/tickets/LDEV0563/mysql/Application.cfc @@ -5,32 +5,11 @@ component { mySQL = getCredentials(); - this.datasources["DSN1"] = { - class: 'org.gjt.mm.mysql.Driver' - , bundleName:'com.mysql.jdbc' - , bundleVersion:'5.1.38' - , connectionString: 'jdbc:mysql://'&mySQL.server&':'&mySQL.port&'/'&mySQL.database&'?useUnicode=true&characterEncoding=UTF-8&useLegacyDatetimeCode=true' - , username: mySQL.username - , password: mySQL.password - }; + this.datasources["DSN1"] = mySQL; - this.datasources["DSN2"] = { - class: 'org.gjt.mm.mysql.Driver' - , bundleName:'com.mysql.jdbc' - , bundleVersion:'5.1.38' - , connectionString: 'jdbc:mysql://'&mySQL.server&':'&mySQL.port&'/'&mySQL.database&'?useUnicode=true&characterEncoding=UTF-8&useLegacyDatetimeCode=true' - , username: mySQL.username - , password: mySQL.password - }; + this.datasources["DSN2"] = mysql; - this.datasources["DSN3"] = { - class: 'org.gjt.mm.mysql.Driver' - , bundleName:'com.mysql.jdbc' - , bundleVersion:'5.1.38' - , connectionString: 'jdbc:mysql://'&mySQL.server&':'&mySQL.port&'/'&mySQL.database&'?useUnicode=true&characterEncoding=UTF-8&useLegacyDatetimeCode=true' - , username: mySQL.username - , password: mySQL.password - }; + this.datasources["DSN3"] = mysql; this.datasource = "DSN1"; @@ -58,40 +37,6 @@ component { // Private function to get dsn details from env vars private struct function getCredentials() { - // getting the credentials from the environment variables - var mySQL={}; - if(isNull(server.system)){ - server.system = structNew(); - currSystem = createObject("java", "java.lang.System"); - server.system.environment = currSystem.getenv(); - server.system.properties = currSystem.getproperties(); - } - - if( - !isNull(server.system.environment.MYSQL_SERVER) && - !isNull(server.system.environment.MYSQL_USERNAME) && - !isNull(server.system.environment.MYSQL_PASSWORD) && - !isNull(server.system.environment.MYSQL_PORT) && - !isNull(server.system.environment.MYSQL_DATABASE)) { - mySQL.server=server.system.environment.MYSQL_SERVER; - mySQL.username=server.system.environment.MYSQL_USERNAME; - mySQL.password=server.system.environment.MYSQL_PASSWORD; - mySQL.port=server.system.environment.MYSQL_PORT; - mySQL.database=server.system.environment.MYSQL_DATABASE; - } - // getting the credentials from the system variables - else if( - !isNull(server.system.properties.MYSQL_SERVER) && - !isNull(server.system.properties.MYSQL_USERNAME) && - !isNull(server.system.properties.MYSQL_PASSWORD) && - !isNull(server.system.properties.MYSQL_PORT) && - !isNull(server.system.properties.MYSQL_DATABASE)) { - mySQL.server=server.system.properties.MYSQL_SERVER; - mySQL.username=server.system.properties.MYSQL_USERNAME; - mySQL.password=server.system.properties.MYSQL_PASSWORD; - mySQL.port=server.system.properties.MYSQL_PORT; - mySQL.database=server.system.properties.MYSQL_DATABASE; - } - return mysql; + return server.getDatasource("mysql"); } } \ No newline at end of file diff --git a/test/tickets/LDEV0826.cfc b/test/tickets/LDEV0826.cfc index 070cba290c..eb14713a99 100644 --- a/test/tickets/LDEV0826.cfc +++ b/test/tickets/LDEV0826.cfc @@ -59,15 +59,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase" { var mySQL=getCredencials(); if(mySQL.count()==0) return false; application action="update" - datasource="# { - class: 'org.gjt.mm.mysql.Driver' - , bundleName:'com.mysql.jdbc' - , bundleVersion:'5.1.38' - , connectionString: 'jdbc:mysql://'&mySQL.server&':'&mySQL.port&'/'&mySQL.database&'?useUnicode=true&characterEncoding=UTF-8&useLegacyDatetimeCode=true' - , username: mySQL.username - , password: mySQL.password - , connectionLimit:100 // default:-1 -}#"; + datasource="#mysql#"; return true; } @@ -76,34 +68,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase" { private struct function getCredencials() { - // getting the credetials from the enviroment variables - var mySQL={}; - if( - !isNull(server.system.environment.MYSQL_SERVER) && - !isNull(server.system.environment.MYSQL_USERNAME) && - !isNull(server.system.environment.MYSQL_PASSWORD) && - !isNull(server.system.environment.MYSQL_PORT) && - !isNull(server.system.environment.MYSQL_DATABASE)) { - mySQL.server=server.system.environment.MYSQL_SERVER; - mySQL.username=server.system.environment.MYSQL_USERNAME; - mySQL.password=server.system.environment.MYSQL_PASSWORD; - mySQL.port=server.system.environment.MYSQL_PORT; - mySQL.database=server.system.environment.MYSQL_DATABASE; - } - // getting the credetials from the system variables - else if( - !isNull(server.system.properties.MYSQL_SERVER) && - !isNull(server.system.properties.MYSQL_USERNAME) && - !isNull(server.system.properties.MYSQL_PASSWORD) && - !isNull(server.system.properties.MYSQL_PORT) && - !isNull(server.system.properties.MYSQL_DATABASE)) { - mySQL.server=server.system.properties.MYSQL_SERVER; - mySQL.username=server.system.properties.MYSQL_USERNAME; - mySQL.password=server.system.properties.MYSQL_PASSWORD; - mySQL.port=server.system.properties.MYSQL_PORT; - mySQL.database=server.system.properties.MYSQL_DATABASE; - } - return mysql; + return server.getDatasource('mysql') } } \ No newline at end of file diff --git a/test/tickets/LDEV0931.cfc b/test/tickets/LDEV0931.cfc index c9e6dccbf5..2c3b2bc756 100644 --- a/test/tickets/LDEV0931.cfc +++ b/test/tickets/LDEV0931.cfc @@ -16,7 +16,7 @@ * License along with this library. If not, see . * ---> -component extends="org.lucee.cfml.test.LuceeTestCase" { +component extends="org.lucee.cfml.test.LuceeTestCase" skip=true { public void function testImplicit(){ var data=chr(228)&chr(246)&chr(252); // äöü diff --git a/test/tickets/LDEV1176.cfc b/test/tickets/LDEV1176.cfc index 21051dbaaa..1a27d0fba3 100644 --- a/test/tickets/LDEV1176.cfc +++ b/test/tickets/LDEV1176.cfc @@ -1,6 +1,7 @@ -component extends="org.lucee.cfml.test.LuceeTestCase"{ +component extends="org.lucee.cfml.test.LuceeTestCase" labels="s3" skip=true { // skip closure function isNotSupported() { + return true; variables.s3Details=getCredentials(); if(!isNull(variables.s3Details.ACCESSKEYID) && !isNull(variables.s3Details.AWSSECRETKEY)) { variables.supported = true; diff --git a/test/tickets/LDEV1229.cfc b/test/tickets/LDEV1229.cfc index 6aad24ff5f..7a2393a5ae 100644 --- a/test/tickets/LDEV1229.cfc +++ b/test/tickets/LDEV1229.cfc @@ -32,40 +32,6 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{ } private boolean function checkMySqlEnvVarsAvailable() { - // getting the credentials from the environment variables - var mySQL={}; - if(isNull(server.system)){ - server.system = structNew(); - currSystem = createObject("java", "java.lang.System"); - server.system.environment = currSystem.getenv(); - server.system.properties = currSystem.getproperties(); - } - - if( - !isNull(server.system.environment.MYSQL_SERVER) && - !isNull(server.system.environment.MYSQL_USERNAME) && - !isNull(server.system.environment.MYSQL_PASSWORD) && - !isNull(server.system.environment.MYSQL_PORT) && - !isNull(server.system.environment.MYSQL_DATABASE)) { - mySQL.server=server.system.environment.MYSQL_SERVER; - mySQL.username=server.system.environment.MYSQL_USERNAME; - mySQL.password=server.system.environment.MYSQL_PASSWORD; - mySQL.port=server.system.environment.MYSQL_PORT; - mySQL.database=server.system.environment.MYSQL_DATABASE; - } - // getting the credentials from the system variables - else if( - !isNull(server.system.properties.MYSQL_SERVER) && - !isNull(server.system.properties.MYSQL_USERNAME) && - !isNull(server.system.properties.MYSQL_PASSWORD) && - !isNull(server.system.properties.MYSQL_PORT) && - !isNull(server.system.properties.MYSQL_DATABASE)) { - mySQL.server=server.system.properties.MYSQL_SERVER; - mySQL.username=server.system.properties.MYSQL_USERNAME; - mySQL.password=server.system.properties.MYSQL_PASSWORD; - mySQL.port=server.system.properties.MYSQL_PORT; - mySQL.database=server.system.properties.MYSQL_DATABASE; - } - return structIsEmpty(mySQL); + return structIsEmpty(server.getDatasource("mysql")); } } diff --git a/test/tickets/LDEV1229/Application.cfc b/test/tickets/LDEV1229/Application.cfc index 9715a862f3..8efb94aacd 100644 --- a/test/tickets/LDEV1229/Application.cfc +++ b/test/tickets/LDEV1229/Application.cfc @@ -14,14 +14,7 @@ component { else { mySQL = getCredentials(); if(mySQL.count()!=0){ - this.datasource={ - class: 'org.gjt.mm.mysql.Driver' - , bundleName:'com.mysql.jdbc' - , bundleVersion:'5.1.38' - , connectionString: 'jdbc:mysql://'&mySQL.server&':'&mySQL.port&'/'&mySQL.database&'?useUnicode=true&characterEncoding=UTF-8&useLegacyDatetimeCode=true' - , username: mySQL.username - , password: mySQL.password - }; + this.datasource=mysql } } @@ -68,33 +61,6 @@ component { } private struct function getCredentials() { - // getting the credentials from the enviroment variables - var mySQL={}; - if( - !isNull(server.system.environment.MYSQL_SERVER) && - !isNull(server.system.environment.MYSQL_USERNAME) && - !isNull(server.system.environment.MYSQL_PASSWORD) && - !isNull(server.system.environment.MYSQL_PORT) && - !isNull(server.system.environment.MYSQL_DATABASE)) { - mySQL.server=server.system.environment.MYSQL_SERVER; - mySQL.username=server.system.environment.MYSQL_USERNAME; - mySQL.password=server.system.environment.MYSQL_PASSWORD; - mySQL.port=server.system.environment.MYSQL_PORT; - mySQL.database=server.system.environment.MYSQL_DATABASE; - } - // getting the credentials from the system variables - else if( - !isNull(server.system.properties.MYSQL_SERVER) && - !isNull(server.system.properties.MYSQL_USERNAME) && - !isNull(server.system.properties.MYSQL_PASSWORD) && - !isNull(server.system.properties.MYSQL_PORT) && - !isNull(server.system.properties.MYSQL_DATABASE)) { - mySQL.server=server.system.properties.MYSQL_SERVER; - mySQL.username=server.system.properties.MYSQL_USERNAME; - mySQL.password=server.system.properties.MYSQL_PASSWORD; - mySQL.port=server.system.properties.MYSQL_PORT; - mySQL.database=server.system.properties.MYSQL_DATABASE; - } - return mysql; + return server.getDatasource("mysql"); } } \ No newline at end of file diff --git a/test/tickets/LDEV1292.cfc b/test/tickets/LDEV1292.cfc index 5b68796b4c..06515812bb 100644 --- a/test/tickets/LDEV1292.cfc +++ b/test/tickets/LDEV1292.cfc @@ -48,48 +48,13 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{ } private struct function getCredentials() { - // getting the credentials from the enviroment variables - - var mySQL={}; - if( - !isNull(server.system.environment.MYSQL_SERVER) && - !isNull(server.system.environment.MYSQL_USERNAME) && - !isNull(server.system.environment.MYSQL_PASSWORD) && - !isNull(server.system.environment.MYSQL_PORT) && - !isNull(server.system.environment.MYSQL_DATABASE)) { - mySQL.server=server.system.environment.MYSQL_SERVER; - mySQL.username=server.system.environment.MYSQL_USERNAME; - mySQL.password=server.system.environment.MYSQL_PASSWORD; - mySQL.port=server.system.environment.MYSQL_PORT; - mySQL.database=server.system.environment.MYSQL_DATABASE; - } - // getting the credentials from the system variables - else if( - !isNull(server.system.properties.MYSQL_SERVER) && - !isNull(server.system.properties.MYSQL_USERNAME) && - !isNull(server.system.properties.MYSQL_PASSWORD) && - !isNull(server.system.properties.MYSQL_PORT) && - !isNull(server.system.properties.MYSQL_DATABASE)) { - mySQL.server=server.system.properties.MYSQL_SERVER; - mySQL.username=server.system.properties.MYSQL_USERNAME; - mySQL.password=server.system.properties.MYSQL_PASSWORD; - mySQL.port=server.system.properties.MYSQL_PORT; - mySQL.database=server.system.properties.MYSQL_DATABASE; - } - return mysql; + return server.getDatasource("mysql"); } private string function defineDatasource(){ var mySql = getCredentials(); application action="update" - datasource="#{ - class: 'org.gjt.mm.mysql.Driver' - , bundleName:'com.mysql.jdbc' - , bundleVersion:'5.1.38' - , connectionString: 'jdbc:mysql://'&mySQL.server&':'&mySQL.port&'/'&mySQL.database&'?useUnicode=true&characterEncoding=UTF-8&useLegacyDatetimeCode=true' - , username: mySQL.username - , password: mySQL.password - }#"; + datasource="#server.getDatasource('mysql')#"; } private function createTable() { diff --git a/test/tickets/LDEV1292/test1/Application.cfc b/test/tickets/LDEV1292/test1/Application.cfc index a9a4cd5a50..6ceb0ee488 100644 --- a/test/tickets/LDEV1292/test1/Application.cfc +++ b/test/tickets/LDEV1292/test1/Application.cfc @@ -1,45 +1,4 @@ component { this.name = "test"; - mySQL= getCredentials(); - this.datasource = { - type: "mysql" - ,host: "#mySQL.server#" - ,port: "#mySQL.port#" - ,database: "#mySQL.database#" - ,username: "#mySQL.username#" - ,password: "#mySQL.password#" - ,custom: { useUnicode:true } - }; - - private struct function getCredentials() { - // getting the credentials from the enviroment variables - - var mySQL={}; - if( - !isNull(server.system.environment.MYSQL_SERVER) && - !isNull(server.system.environment.MYSQL_USERNAME) && - !isNull(server.system.environment.MYSQL_PASSWORD) && - !isNull(server.system.environment.MYSQL_PORT) && - !isNull(server.system.environment.MYSQL_DATABASE)) { - mySQL.server=server.system.environment.MYSQL_SERVER; - mySQL.username=server.system.environment.MYSQL_USERNAME; - mySQL.password=server.system.environment.MYSQL_PASSWORD; - mySQL.port=server.system.environment.MYSQL_PORT; - mySQL.database=server.system.environment.MYSQL_DATABASE; - } - // getting the credentials from the system variables - else if( - !isNull(server.system.properties.MYSQL_SERVER) && - !isNull(server.system.properties.MYSQL_USERNAME) && - !isNull(server.system.properties.MYSQL_PASSWORD) && - !isNull(server.system.properties.MYSQL_PORT) && - !isNull(server.system.properties.MYSQL_DATABASE)) { - mySQL.server=server.system.properties.MYSQL_SERVER; - mySQL.username=server.system.properties.MYSQL_USERNAME; - mySQL.password=server.system.properties.MYSQL_PASSWORD; - mySQL.port=server.system.properties.MYSQL_PORT; - mySQL.database=server.system.properties.MYSQL_DATABASE; - } - return mysql; - } + this.datasource = server.getDatasource("mysql"); } \ No newline at end of file diff --git a/test/tickets/LDEV1292/test2/Application.cfc b/test/tickets/LDEV1292/test2/Application.cfc index a9a4cd5a50..c8e9947812 100644 --- a/test/tickets/LDEV1292/test2/Application.cfc +++ b/test/tickets/LDEV1292/test2/Application.cfc @@ -1,45 +1,4 @@ component { this.name = "test"; - mySQL= getCredentials(); - this.datasource = { - type: "mysql" - ,host: "#mySQL.server#" - ,port: "#mySQL.port#" - ,database: "#mySQL.database#" - ,username: "#mySQL.username#" - ,password: "#mySQL.password#" - ,custom: { useUnicode:true } - }; - - private struct function getCredentials() { - // getting the credentials from the enviroment variables - - var mySQL={}; - if( - !isNull(server.system.environment.MYSQL_SERVER) && - !isNull(server.system.environment.MYSQL_USERNAME) && - !isNull(server.system.environment.MYSQL_PASSWORD) && - !isNull(server.system.environment.MYSQL_PORT) && - !isNull(server.system.environment.MYSQL_DATABASE)) { - mySQL.server=server.system.environment.MYSQL_SERVER; - mySQL.username=server.system.environment.MYSQL_USERNAME; - mySQL.password=server.system.environment.MYSQL_PASSWORD; - mySQL.port=server.system.environment.MYSQL_PORT; - mySQL.database=server.system.environment.MYSQL_DATABASE; - } - // getting the credentials from the system variables - else if( - !isNull(server.system.properties.MYSQL_SERVER) && - !isNull(server.system.properties.MYSQL_USERNAME) && - !isNull(server.system.properties.MYSQL_PASSWORD) && - !isNull(server.system.properties.MYSQL_PORT) && - !isNull(server.system.properties.MYSQL_DATABASE)) { - mySQL.server=server.system.properties.MYSQL_SERVER; - mySQL.username=server.system.properties.MYSQL_USERNAME; - mySQL.password=server.system.properties.MYSQL_PASSWORD; - mySQL.port=server.system.properties.MYSQL_PORT; - mySQL.database=server.system.properties.MYSQL_DATABASE; - } - return mysql; - } + this.datasource = this.datasource = server.getDatasource("mysql"); } \ No newline at end of file diff --git a/test/tickets/LDEV1576.cfc b/test/tickets/LDEV1576.cfc index da9efa5460..81cc449b7e 100644 --- a/test/tickets/LDEV1576.cfc +++ b/test/tickets/LDEV1576.cfc @@ -28,35 +28,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{ } private struct function getCredentials() { - // getting the credentials from the enviroment variables - - var mySQL={}; - if( - !isNull(server.system.environment.MYSQL_SERVER) && - !isNull(server.system.environment.MYSQL_USERNAME) && - !isNull(server.system.environment.MYSQL_PASSWORD) && - !isNull(server.system.environment.MYSQL_PORT) && - !isNull(server.system.environment.MYSQL_DATABASE)) { - mySQL.server=server.system.environment.MYSQL_SERVER; - mySQL.username=server.system.environment.MYSQL_USERNAME; - mySQL.password=server.system.environment.MYSQL_PASSWORD; - mySQL.port=server.system.environment.MYSQL_PORT; - mySQL.database=server.system.environment.MYSQL_DATABASE; - } - // getting the credentials from the system variables - else if( - !isNull(server.system.properties.MYSQL_SERVER) && - !isNull(server.system.properties.MYSQL_USERNAME) && - !isNull(server.system.properties.MYSQL_PASSWORD) && - !isNull(server.system.properties.MYSQL_PORT) && - !isNull(server.system.properties.MYSQL_DATABASE)) { - mySQL.server=server.system.properties.MYSQL_SERVER; - mySQL.username=server.system.properties.MYSQL_USERNAME; - mySQL.password=server.system.properties.MYSQL_PASSWORD; - mySQL.port=server.system.properties.MYSQL_PORT; - mySQL.database=server.system.properties.MYSQL_DATABASE; - } - return mysql; + return server.getDatasource("mysql"); } } \ No newline at end of file diff --git a/test/tickets/LDEV1576/Application.cfc b/test/tickets/LDEV1576/Application.cfc index ea74a6c24f..4372117585 100644 --- a/test/tickets/LDEV1576/Application.cfc +++ b/test/tickets/LDEV1576/Application.cfc @@ -1,14 +1,7 @@ component { this.name = "LDEV1576-" & Hash( GetCurrentTemplatePath() ); mySQL = getCredentials(); - this.datasource ={ - class: 'org.gjt.mm.mysql.Driver' - , bundleName:'com.mysql.jdbc' - , bundleVersion:'5.1.38' - , connectionString: 'jdbc:mysql://'&mySQL.server&':'&mySQL.port&'/'&mySQL.database&'?useUnicode=true&characterEncoding=UTF-8&useLegacyDatetimeCode=true' - , username: mySQL.username - , password: mySQL.password - }; + this.datasource = mysql; function onRequestStart(){ setting showdebugOutput=false; @@ -24,40 +17,6 @@ component { } private struct function getCredentials() { - // getting the credentials from the enviroment variables - var mySQL={}; - if(isNull(server.system)){ - server.system = structNew(); - currSystem = createObject("java", "java.lang.System"); - server.system.environment = currSystem.getenv(); - server.system.properties = currSystem.getproperties(); - } - - if( - !isNull(server.system.environment.MYSQL_SERVER) && - !isNull(server.system.environment.MYSQL_USERNAME) && - !isNull(server.system.environment.MYSQL_PASSWORD) && - !isNull(server.system.environment.MYSQL_PORT) && - !isNull(server.system.environment.MYSQL_DATABASE)) { - mySQL.server=server.system.environment.MYSQL_SERVER; - mySQL.username=server.system.environment.MYSQL_USERNAME; - mySQL.password=server.system.environment.MYSQL_PASSWORD; - mySQL.port=server.system.environment.MYSQL_PORT; - mySQL.database=server.system.environment.MYSQL_DATABASE; - } - // getting the credentials from the system variables - else if( - !isNull(server.system.properties.MYSQL_SERVER) && - !isNull(server.system.properties.MYSQL_USERNAME) && - !isNull(server.system.properties.MYSQL_PASSWORD) && - !isNull(server.system.properties.MYSQL_PORT) && - !isNull(server.system.properties.MYSQL_DATABASE)) { - mySQL.server=server.system.properties.MYSQL_SERVER; - mySQL.username=server.system.properties.MYSQL_USERNAME; - mySQL.password=server.system.properties.MYSQL_PASSWORD; - mySQL.port=server.system.properties.MYSQL_PORT; - mySQL.database=server.system.properties.MYSQL_DATABASE; - } - return mysql; + return server.getDatasource("mysql"); } } diff --git a/test/tickets/LDEV1661.cfc b/test/tickets/LDEV1661.cfc index 3f5de0f035..bd27494cd7 100644 --- a/test/tickets/LDEV1661.cfc +++ b/test/tickets/LDEV1661.cfc @@ -47,35 +47,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{ } private struct function getCredentials() { - // getting the credentials from the enviroment variables - - var mySQL={}; - if( - !isNull(server.system.environment.MYSQL_SERVER) && - !isNull(server.system.environment.MYSQL_USERNAME) && - !isNull(server.system.environment.MYSQL_PASSWORD) && - !isNull(server.system.environment.MYSQL_PORT) && - !isNull(server.system.environment.MYSQL_DATABASE)) { - mySQL.server=server.system.environment.MYSQL_SERVER; - mySQL.username=server.system.environment.MYSQL_USERNAME; - mySQL.password=server.system.environment.MYSQL_PASSWORD; - mySQL.port=server.system.environment.MYSQL_PORT; - mySQL.database=server.system.environment.MYSQL_DATABASE; - } - // getting the credentials from the system variables - else if( - !isNull(server.system.properties.MYSQL_SERVER) && - !isNull(server.system.properties.MYSQL_USERNAME) && - !isNull(server.system.properties.MYSQL_PASSWORD) && - !isNull(server.system.properties.MYSQL_PORT) && - !isNull(server.system.properties.MYSQL_DATABASE)) { - mySQL.server=server.system.properties.MYSQL_SERVER; - mySQL.username=server.system.properties.MYSQL_USERNAME; - mySQL.password=server.system.properties.MYSQL_PASSWORD; - mySQL.port=server.system.properties.MYSQL_PORT; - mySQL.database=server.system.properties.MYSQL_DATABASE; - } - return mysql; + return server.getDatasource("mysql"); } } diff --git a/test/tickets/LDEV1661/Application.cfc b/test/tickets/LDEV1661/Application.cfc index 7ab3b22876..3c3aa57fe0 100644 --- a/test/tickets/LDEV1661/Application.cfc +++ b/test/tickets/LDEV1661/Application.cfc @@ -1,14 +1,7 @@ component { this.name = "tests345"; mySQL = getCredentials(); - this.datasource ={ - class: 'com.mysql.cj.jdbc.Driver' - , bundleName:'com.mysql.cj' - , bundleVersion:'6.0.5' - , connectionString: 'jdbc:mysql://'&mySQL.server&':'&mySQL.port&'/'&mySQL.database&'?useUnicode=true&characterEncoding=UTF-8&useLegacyDatetimeCode=true' - , username: mySQL.username - , password: mySQL.password - }; + this.datasource = mysql; function onRequestStart(){ setting showdebugOutput=false; @@ -27,40 +20,6 @@ component { } private struct function getCredentials() { - // getting the credentials from the enviroment variables - var mySQL={}; - if(isNull(server.system)){ - server.system = structNew(); - currSystem = createObject("java", "java.lang.System"); - server.system.environment = currSystem.getenv(); - server.system.properties = currSystem.getproperties(); - } - - if( - !isNull(server.system.environment.MYSQL_SERVER) && - !isNull(server.system.environment.MYSQL_USERNAME) && - !isNull(server.system.environment.MYSQL_PASSWORD) && - !isNull(server.system.environment.MYSQL_PORT) && - !isNull(server.system.environment.MYSQL_DATABASE)) { - mySQL.server=server.system.environment.MYSQL_SERVER; - mySQL.username=server.system.environment.MYSQL_USERNAME; - mySQL.password=server.system.environment.MYSQL_PASSWORD; - mySQL.port=server.system.environment.MYSQL_PORT; - mySQL.database=server.system.environment.MYSQL_DATABASE; - } - // getting the credentials from the system variables - else if( - !isNull(server.system.properties.MYSQL_SERVER) && - !isNull(server.system.properties.MYSQL_USERNAME) && - !isNull(server.system.properties.MYSQL_PASSWORD) && - !isNull(server.system.properties.MYSQL_PORT) && - !isNull(server.system.properties.MYSQL_DATABASE)) { - mySQL.server=server.system.properties.MYSQL_SERVER; - mySQL.username=server.system.properties.MYSQL_USERNAME; - mySQL.password=server.system.properties.MYSQL_PASSWORD; - mySQL.port=server.system.properties.MYSQL_PORT; - mySQL.database=server.system.properties.MYSQL_DATABASE; - } - return mysql; + return server.getDatasource("mysql") } } diff --git a/test/tickets/LDEV1793.cfc b/test/tickets/LDEV1793.cfc index 48874dca9e..b92d7e4bcd 100644 --- a/test/tickets/LDEV1793.cfc +++ b/test/tickets/LDEV1793.cfc @@ -28,34 +28,6 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{ } private struct function getCredentials() { - // getting the credentials from the enviroment variables - - var mySQL={}; - if( - !isNull(server.system.environment.MYSQL_SERVER) && - !isNull(server.system.environment.MYSQL_USERNAME) && - !isNull(server.system.environment.MYSQL_PASSWORD) && - !isNull(server.system.environment.MYSQL_PORT) && - !isNull(server.system.environment.MYSQL_DATABASE)) { - mySQL.server=server.system.environment.MYSQL_SERVER; - mySQL.username=server.system.environment.MYSQL_USERNAME; - mySQL.password=server.system.environment.MYSQL_PASSWORD; - mySQL.port=server.system.environment.MYSQL_PORT; - mySQL.database=server.system.environment.MYSQL_DATABASE; - } - // getting the credentials from the system variables - else if( - !isNull(server.system.properties.MYSQL_SERVER) && - !isNull(server.system.properties.MYSQL_USERNAME) && - !isNull(server.system.properties.MYSQL_PASSWORD) && - !isNull(server.system.properties.MYSQL_PORT) && - !isNull(server.system.properties.MYSQL_DATABASE)) { - mySQL.server=server.system.properties.MYSQL_SERVER; - mySQL.username=server.system.properties.MYSQL_USERNAME; - mySQL.password=server.system.properties.MYSQL_PASSWORD; - mySQL.port=server.system.properties.MYSQL_PORT; - mySQL.database=server.system.properties.MYSQL_DATABASE; - } - return mysql; + return server.getDatasource("mysql"); } } \ No newline at end of file diff --git a/test/tickets/LDEV1793/Application.cfc b/test/tickets/LDEV1793/Application.cfc index f0e2c36ecf..8a67e5583f 100644 --- a/test/tickets/LDEV1793/Application.cfc +++ b/test/tickets/LDEV1793/Application.cfc @@ -5,14 +5,7 @@ component { mySQL = getCredentials(); if(mySQL.count()!=0){ - this.datasource ="#{ - class: 'org.gjt.mm.mysql.Driver' - , bundleName:'com.mysql.jdbc' - , bundleVersion:'5.1.38' - , connectionString: 'jdbc:mysql://'&mySQL.server&':'&mySQL.port&'/'&mySQL.database&'?useUnicode=true&characterEncoding=UTF-8&useLegacyDatetimeCode=true' - , username: mySQL.username - , password: mySQL.password - }#"; + this.datasource = mysql; } // ORM settings @@ -40,34 +33,7 @@ component { } private struct function getCredentials() { - // getting the credentials from the enviroment variables - var mySQL={}; - if( - !isNull(server.system.environment.MYSQL_SERVER) && - !isNull(server.system.environment.MYSQL_USERNAME) && - !isNull(server.system.environment.MYSQL_PASSWORD) && - !isNull(server.system.environment.MYSQL_PORT) && - !isNull(server.system.environment.MYSQL_DATABASE)) { - mySQL.server=server.system.environment.MYSQL_SERVER; - mySQL.username=server.system.environment.MYSQL_USERNAME; - mySQL.password=server.system.environment.MYSQL_PASSWORD; - mySQL.port=server.system.environment.MYSQL_PORT; - mySQL.database=server.system.environment.MYSQL_DATABASE; - } - // getting the credentials from the system variables - else if( - !isNull(server.system.properties.MYSQL_SERVER) && - !isNull(server.system.properties.MYSQL_USERNAME) && - !isNull(server.system.properties.MYSQL_PASSWORD) && - !isNull(server.system.properties.MYSQL_PORT) && - !isNull(server.system.properties.MYSQL_DATABASE)) { - mySQL.server=server.system.properties.MYSQL_SERVER; - mySQL.username=server.system.properties.MYSQL_USERNAME; - mySQL.password=server.system.properties.MYSQL_PASSWORD; - mySQL.port=server.system.properties.MYSQL_PORT; - mySQL.database=server.system.properties.MYSQL_DATABASE; - } - return mysql; + return server.getDatasource("mysql"); } } \ No newline at end of file diff --git a/test/tickets/LDEV1980.cfc b/test/tickets/LDEV1980.cfc index 79993b82c3..65491fc83f 100644 --- a/test/tickets/LDEV1980.cfc +++ b/test/tickets/LDEV1980.cfc @@ -32,19 +32,10 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{ query name="test" datasource=ds { echo( " create table `TestDsnTBL`(id varchar(10),Personname varchar(10))" - ); + ); } } - - function afterAll(){ - if(isNotSupported()) return; - query name="test" datasource=getDatasource() { - echo( " - DROP DATABASE IF EXISTS `LDEV1980DB` - "); - } - } - + function isNotSupported() { var mySql = getCredentials(); if(!isNull(mysql) && structCount(mySql)){ @@ -57,52 +48,14 @@ component extends="org.lucee.cfml.test.LuceeTestCase"{ private function getDatasource() { var cred=getCredentials(); if(structCount(cred)>0){ - return { - class: 'com.mysql.cj.jdbc.Driver' - , bundleName:'com.mysql.cj' - , connectionString: 'jdbc:mysql://'& - cred.server&':'& - cred.port&'/'& - cred.database&'?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GB&useLegacyDatetimeCode=true' - , username: cred.username - , password: cred.password - ,storage:true - }; + cred.storage = true; + return cred; } return {}; } - - private struct function getCredentials() { // getting the credentials from the enviroment variables - var mySQLStruct={}; - if( - !isNull(server.system.environment.MYSQL_SERVER) && - !isNull(server.system.environment.MYSQL_USERNAME) && - !isNull(server.system.environment.MYSQL_PASSWORD) && - !isNull(server.system.environment.MYSQL_PORT) && - !isNull(server.system.environment.MYSQL_DATABASE)) { - mySQLStruct.server=server.system.environment.MYSQL_SERVER; - mySQLStruct.username=server.system.environment.MYSQL_USERNAME; - mySQLStruct.password=server.system.environment.MYSQL_PASSWORD; - mySQLStruct.port=server.system.environment.MYSQL_PORT; - mySQLStruct.database=server.system.environment.MYSQL_DATABASE; - } - // getting the credentials from the system variables - else if( - !isNull(server.system.properties.MYSQL_SERVER) && - !isNull(server.system.properties.MYSQL_USERNAME) && - !isNull(server.system.properties.MYSQL_PASSWORD) && - !isNull(server.system.properties.MYSQL_PORT) && - !isNull(server.system.properties.MYSQL_DATABASE)) { - mySQLStruct.server=server.system.properties.MYSQL_SERVER; - mySQLStruct.username=server.system.properties.MYSQL_USERNAME; - mySQLStruct.password=server.system.properties.MYSQL_PASSWORD; - mySQLStruct.port=server.system.properties.MYSQL_PORT; - mySQLStruct.database=server.system.properties.MYSQL_DATABASE; - } - - return mySQLStruct; + return server.getDatasource("mysql"); } } \ No newline at end of file diff --git a/test/tickets/LDEV2266.cfc b/test/tickets/LDEV2266.cfc index 78a05ef97e..e1016d1262 100644 --- a/test/tickets/LDEV2266.cfc +++ b/test/tickets/LDEV2266.cfc @@ -55,14 +55,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase" { var mySQL=getCredencials(); var has=false; if(mySQL.count()>0) { - var ds['mysql']={ - class: 'org.gjt.mm.mysql.Driver' - , bundleName:'com.mysql.jdbc' - , bundleVersion:'5.1.38' - , connectionString: 'jdbc:mysql://'&mySQL.server&':'&mySQL.port&'/'&mySQL.database&'?useUnicode=true&characterEncoding=UTF-8&useLegacyDatetimeCode=true' - , username: mySQL.username - , password: mySQL.password - }; + var ds['mysql']=mysql; has=true; } @@ -72,34 +65,6 @@ component extends="org.lucee.cfml.test.LuceeTestCase" { } private struct function getCredencials() { - // getting the credetials from the enviroment variables - var mySQL={}; - if( - !isNull(server.system.environment.MYSQL_SERVER) && - !isNull(server.system.environment.MYSQL_USERNAME) && - !isNull(server.system.environment.MYSQL_PASSWORD) && - !isNull(server.system.environment.MYSQL_PORT) && - !isNull(server.system.environment.MYSQL_DATABASE)) { - mySQL.server=server.system.environment.MYSQL_SERVER; - mySQL.username=server.system.environment.MYSQL_USERNAME; - mySQL.password=server.system.environment.MYSQL_PASSWORD; - mySQL.port=server.system.environment.MYSQL_PORT; - mySQL.database=server.system.environment.MYSQL_DATABASE; - } - // getting the credetials from the system variables - else if( - !isNull(server.system.properties.MYSQL_SERVER) && - !isNull(server.system.properties.MYSQL_USERNAME) && - !isNull(server.system.properties.MYSQL_PASSWORD) && - !isNull(server.system.properties.MYSQL_PORT) && - !isNull(server.system.properties.MYSQL_DATABASE)) { - mySQL.server=server.system.properties.MYSQL_SERVER; - mySQL.username=server.system.properties.MYSQL_USERNAME; - mySQL.password=server.system.properties.MYSQL_PASSWORD; - mySQL.port=server.system.properties.MYSQL_PORT; - mySQL.database=server.system.properties.MYSQL_DATABASE; - } - - return mysql; + return server.getDatasource("mysql"); } } \ No newline at end of file diff --git a/test/tickets/LDEV2586.cfc b/test/tickets/LDEV2586.cfc index 81d37854f3..bf6bd99eaa 100644 --- a/test/tickets/LDEV2586.cfc +++ b/test/tickets/LDEV2586.cfc @@ -7,15 +7,7 @@ component extends = "org.lucee.cfml.test.LuceeTestCase"{ if(structCount(variables.credencials)) { // define datasource application action="update" - datasource={ - 'LDEV2586': { - class: 'com.microsoft.sqlserver.jdbc.SQLServerDriver' - , bundleName: 'com.microsoft.sqlserver.mssql-jdbc' - , bundleVersion: '7.0.0' - , connectionString: 'jdbc:sqlserver://'&msSQL.server&':'&msSQL.port&';DATABASENAME='&msSQL.database&';sendStringParametersAsUnicode=true;SelectMethod=direct' - , username: msSQL.username - , password: msSQL.password - }}; + datasource=variables.credencials; // create necessary tables query datasource="LDEV2586" { @@ -90,33 +82,6 @@ component extends = "org.lucee.cfml.test.LuceeTestCase"{ } private struct function getCredencials() { - // getting the credetials from the enviroment variables - var msSQL={}; - if( - !isNull(server.system.environment.MSSQL_SERVER) && - !isNull(server.system.environment.MSSQL_USERNAME) && - !isNull(server.system.environment.MSSQL_PASSWORD) && - !isNull(server.system.environment.MSSQL_PORT) && - !isNull(server.system.environment.MSSQL_DATABASE)) { - msSQL.server=server.system.environment.MSSQL_SERVER; - msSQL.username=server.system.environment.MSSQL_USERNAME; - msSQL.password=server.system.environment.MSSQL_PASSWORD; - msSQL.port=server.system.environment.MSSQL_PORT; - msSQL.database=server.system.environment.MSSQL_DATABASE; - } - // getting the credetials from the system variables - else if( - !isNull(server.system.properties.MSSQL_SERVER) && - !isNull(server.system.properties.MSSQL_USERNAME) && - !isNull(server.system.properties.MSSQL_PASSWORD) && - !isNull(server.system.properties.MSSQL_PORT) && - !isNull(server.system.properties.MSSQL_DATABASE)) { - msSQL.server=server.system.properties.MSSQL_SERVER; - msSQL.username=server.system.properties.MSSQL_USERNAME; - msSQL.password=server.system.properties.MSSQL_PASSWORD; - msSQL.port=server.system.properties.MSSQL_PORT; - msSQL.database=server.system.properties.MSSQL_DATABASE; - } - return msSQL; + return server.getDatasource('mssql'); } }