<commit_before><!--- 
 *
 * Copyright (c) 2016, Lucee Assosication Switzerland. All rights reserved.*
 * Copyright (c) 2014, the Railo Company LLC. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either 
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public 
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 * 
 ---><cfscript>
component extends="org.lucee.cfml.test.LuceeTestCase"	{
	
	
	//public function afterTests(){}
	
	public function setUp(){
		variables.has=defineDatasource();
	}

	public void function testMySQLWithBSTTimezone(){
		if(!variables.has) return;
		application action="update" timezone="BST";
		setTimeZone("BST");

		query name="local.qry" {
			echo("select 'a' as a");
		}
		//assertEquals("","");
		
	}

	public void function testMySQLWithLondonTimezone(){
		if(!variables.has) return;
		
		application action="update" timezone="Europe/London";
		setTimeZone("Europe/London");
		
		query name="local.qry" {
			echo("select 'a' as a");
		}
		//assertEquals("","");
		
	}

	public void function testStoredProcIn(){
		if(!variables.has) return;
		
		query {
			echo("DROP PROCEDURE IF EXISTS `proc_IN`");
		}
		query {
			echo("
CREATE PROCEDURE `proc_IN` (IN var1 INT)
BEGIN
    SELECT var1 + 2 AS result;
END
			");
		}

		storedproc procedure="proc_IN" {
			procparam type="in" cfsqltype="cf_sql_varchar" value="2";
			procresult name="local.rsIn" resultset="1";

		}
		assertTrue(isQuery(rsIn));
		assertEquals(1,rsIn.recordcount);
		assertEquals("result",rsIn.columnlist);
		assertEquals(4,rsIn.result);
		
	}

	private string function defineDatasource(){
		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'<commit_msg>add testcase for mysql storedproc<commit_after><!--- 
 *
 * Copyright (c) 2016, Lucee Assosication Switzerland. All rights reserved.*
 * Copyright (c) 2014, the Railo Company LLC. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either 
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public 
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 * 
 ---><cfscript>
component extends="org.lucee.cfml.test.LuceeTestCase"	{
	
	
	//public function afterTests(){}
	
	public function setUp(){
		variables.has=defineDatasource();
	}

	public void function testMySQLWithBSTTimezone(){
		if(!variables.has) return;
		application action="update" timezone="BST";
		setTimeZone("BST");

		query name="local.qry" {
			echo("select 'a' as a");
		}
		//assertEquals("","");
		
	}

	public void function testMySQLWithLondonTimezone(){
		if(!variables.has) return;
		
		application action="update" timezone="Europe/London";
		setTimeZone("Europe/London");
		
		query name="local.qry" {
			echo("select 'a' as a");
		}
		//assertEquals("","");
		
	}

	public void function testStoredProcIn(){
		if(!variables.has) return;
		
		query {
			echo("DROP PROCEDURE IF EXISTS `proc_IN`");
		}
		query {
			echo("
CREATE PROCEDURE `proc_IN` (IN var1 INT)
BEGIN
    SELECT var1 + 2 AS result;
END
			");
		}

		storedproc procedure="proc_IN" {
			procparam type="in" cfsqltype="cf_sql_varchar" value="2";
			procresult name="local.rsIn" resultset="1";

		}
		assertTrue(isQuery(rsIn));
		assertEquals(1,rsIn.recordcount);
		assertEquals("result",rsIn.columnlist);
		assertEquals(4,rsIn.result);
		
	}

	public void function testStoredProcOut(){
		if(!variables.has) return;
		
		query {
			echo("DROP PROCEDURE IF EXISTS `proc_OUT`");
		}
		query {
			echo("
CREATE PROCEDURE `proc_OUT` (OUT var1 VARCHAR(100))
BEGIN
    SET var1 = 'outputvar';
END
			");
		}

		storedproc procedure="proc_OUT" {
			procparam type="out" variable="local.res" cfsqltype="cf_sql_varchar";
		}
		assertEquals("outputvar",res);
		
	}


	private string function defineDatasource(){
		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'
{'fraction_non_alphanumeric': 0.12688172043010754, 'fraction_numerical': 0.009579667644183774, 'mean_word_length': 3.991219512195122, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7429249', 'n_tokens_mistral': 1812, 'n_tokens_neox': 1591, 'n_words': 479}