Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improvements to developer scripts. Changed the self-testing version t…
…o develop (for now).

Changed test_ut_utils to compile properly in Windows7 (UTF-8 using multi-byte emoji)
  • Loading branch information
jgebal committed Aug 26, 2017
commit ace7812ec0addf87362813815c93c8a120c1fdf7
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ env:
- DOCKHER_HUB_REPO="${DOCKER_BASE_TAG:-$UT3_DOCKER_REPO}"
#utPLSQL released version directory
- UTPLSQL_DIR="utPLSQL_latest_release"
- UTPLSQL_CLI_FILE="utPLSQL-cli-develop-test3.zip"
matrix:
- ORACLE_VERSION="${DOCKER_TAG_11G:-11g-r2-xe}" CONNECTION_STR='127.0.0.1:1521/XE' DOCKER_OPTIONS='--shm-size=1g'
- ORACLE_VERSION="${DOCKER_TAG_12C:-12c-r1-se2}" CONNECTION_STR='127.0.0.1:1521/ORCLPDB1' DOCKER_OPTIONS="-v /dev/pdbs:/opt/oracle/oradata/pdbs"
Expand All @@ -68,7 +69,7 @@ before_install:
#- curl -LOk $(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL/releases/latest | awk '/browser_download_url/ { print $2 }' | grep ".zip" | sed 's/"//g')
- git clone --depth=1 --branch=${SELFTESTING_BRANCH:-master} https://github.com/utPLSQL/utPLSQL.git $UTPLSQL_DIR
# download utPLSQL-cli develop
- curl -Lk -o utPLSQL-cli.zip https://bintray.com/viniciusam/utPLSQL-cli/download_file?file_path=utPLSQL-cli-develop-test3.zip
- curl -Lk -o utPLSQL-cli.zip https://bintray.com/viniciusam/utPLSQL-cli/download_file?file_path=${UTPLSQL_CLI_FILE}

install:
#- unzip utPLSQL.zip
Expand Down
3 changes: 2 additions & 1 deletion development/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ git rev-parse && cd "$(git rev-parse --show-cdup)"
. development/env.sh

"${SQLCLI}" sys/${ORACLE_PWD}@//${CONNECTION_STR} AS SYSDBA <<-SQL
set echo on
drop user ${UT3_OWNER} cascade;
drop user ${UT3_RELEASE_VERSION_SCHEMA} cascade;
drop user ${UT3_TESTER} cascade;
Expand All @@ -15,7 +16,7 @@ begin
for i in (
select decode(owner,'PUBLIC','drop public synonym "','drop synonym "'||owner||'"."')|| synonym_name ||'"' drop_orphaned_synonym from dba_synonyms a
where not exists (select null from dba_objects b where a.table_name=b.object_name and a.table_owner=b.owner )
and a.table_owner in ('${UT3_OWNER}','${UT3_RELEASE_VERSION_SCHEMA}','${UT3_TESTER}','${UT3_USER}')
and a.table_owner <> 'SYS'
) loop
execute immediate i.drop_orphaned_synonym;
end loop;
Expand Down
2 changes: 1 addition & 1 deletion development/refresh_sources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ git clone --depth=1 --branch=${SELFTESTING_BRANCH:-master} https://github.com/ut

rm -rf utPLSQL-cli/*
# download beta version of utPLSQL-cli
curl -Lk -o utPLSQL-cli.zip https://bintray.com/viniciusam/utPLSQL-cli/download_file?file_path=utPLSQL-cli-develop-test3.zip
curl -Lk -o utPLSQL-cli.zip https://bintray.com/viniciusam/utPLSQL-cli/download_file?file_path=${UTPLSQL_CLI_FILE}
# unzip utPLSQL-cli and remove the zip file
unzip utPLSQL-cli.zip && chmod u+x utPLSQL-cli/bin/utplsql && rm utPLSQL-cli.zip

3 changes: 2 additions & 1 deletion development/template.env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ export SQLCLI=sql # For sqlcl client
#export SQLCLI=sqlplus # For sqlplus client
export CONNECTION_STR=127.0.0.1:1521/xe # Adjust the connect string
export ORACLE_PWD=oracle # Adjust your local SYS password
export UTPLSQL_CLI_FILE="utPLSQL-cli-develop-test3.zip"
export SELFTESTING_BRANCH=develop

export UTPLSQL_DIR="utPLSQL_latest_release"
export SELFTESTING_BRANCH=master
export UT3_OWNER=ut3
export UT3_OWNER_PASSWORD=ut3
export UT3_RELEASE_VERSION_SCHEMA=ut3_latest_release
Expand Down
2 changes: 2 additions & 0 deletions test/install_and_run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash
set -ev
#goto git root directory
git rev-parse && cd "$(git rev-parse --show-cdup)"

cd test

Expand Down
56 changes: 28 additions & 28 deletions test/ut_utils/test_ut_utils.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -53,33 +53,33 @@ end;]' using p_expected_list;
common_clob_to_table_exec( 'abcdefg,hijk,axa,a', ',', ut3.ut_varchar2_list('abc','def','g','hij','k','axa','a'), 3);
common_clob_to_table_exec( ',a,,c,d,', ',', ut3.ut_varchar2_list('','a','','c','d',''), 1000);
end;

procedure test_to_char is
begin
ut.expect(ut3.ut_utils.test_result_to_char(-1),'test unknown').to_equal('Unknown(-1)');
ut.expect(ut3.ut_utils.test_result_to_char(null),'test unknown').to_equal('Unknown(NULL)');
ut.expect(ut3.ut_utils.test_result_to_char(ut3.ut_utils.tr_success),'test unknown').to_equal(ut3.ut_utils.tr_success_char);
end;

procedure test_to_string_blob is
l_text varchar2(32767) := 'A test char';
l_value blob := utl_raw.cast_to_raw(l_text);
l_expected varchar2(32767) := ''''||rawtohex(l_value)||'''';
l_expected varchar2(32767) := ''''||rawtohex(l_value)||'''';
l_result varchar2(32767);
begin
l_result := ut3.ut_utils.to_String(l_value);
ut.expect(l_result).to_equal(l_expected);
end;

procedure test_to_string_clob is
l_value clob := 'A test char';
l_expected varchar2(32767) := ''''||l_value||'''';
l_result varchar2(32767);
begin
l_result := ut3.ut_utils.to_String(l_value);
ut.expect(l_result).to_equal(l_expected);
end;
end;

procedure test_to_string_date is
l_value date := to_date('2016-12-31 23:59:59', 'yyyy-mm-dd hh24:mi:ss');
l_expected varchar2(100) := '2016-12-31T23:59:59';
Expand All @@ -88,7 +88,7 @@ end;]' using p_expected_list;
l_result := ut3.ut_utils.to_String(l_value);
ut.expect(l_result).to_equal(l_expected);
end;

procedure to_string_null is
begin
ut.expect(ut3.ut_utils.to_String(to_blob(NULL))).to_equal('NULL');
Expand All @@ -97,7 +97,7 @@ end;]' using p_expected_list;
ut.expect(ut3.ut_utils.to_String(to_number(NULL))).to_equal('NULL');
ut.expect(ut3.ut_utils.to_String(to_timestamp(NULL))).to_equal('NULL');
end;

procedure to_string is
l_value timestamp(9) := to_timestamp('2016-12-31 23:59:59.123456789', 'yyyy-mm-dd hh24:mi:ss.ff');
l_value2 timestamp(9) with local time zone:= to_timestamp('2016-12-31 23:59:59.123456789', 'yyyy-mm-dd hh24:mi:ss.ff');
Expand All @@ -109,25 +109,25 @@ end;]' using p_expected_list;
begin
select substr(value, 1, 1) into l_delimiter from nls_session_parameters t where t.parameter = 'NLS_NUMERIC_CHARACTERS';
l_expected := '2016-12-31T23:59:59'||l_delimiter||'123456789';

l_result := ut3.ut_utils.to_String(l_value);
ut.expect(l_result,'Returns a full string representation of a timestamp with maximum precission').to_equal(l_expected);

l_expected := '2016-12-31T23:59:59'||l_delimiter||'123456789';
l_result := ut3.ut_utils.to_String(l_value2);
ut.expect(l_result,'Returns a full string representation of a timestamp with maximum precission').to_equal(l_expected);
ut.expect(l_result,'Returns a full string representation of a timestamp with maximum precission').to_equal(l_expected);

l_expected := '2016-12-31T23:59:59'||l_delimiter||'123456789 -08:00';

l_result := ut3.ut_utils.to_String(l_value3);
ut.expect(l_result,'Returns a full string representation of a timestamp with maximum precission').to_equal(l_expected);
l_expected := ''''||l_value4||'''';
ut.expect(l_result,'Returns a full string representation of a timestamp with maximum precission').to_equal(l_expected);

l_expected := ''''||l_value4||'''';
l_result := ut3.ut_utils.to_String(l_value4);
ut.expect(l_result,'Returns a varchar2 eclosed in quotes').to_equal(l_expected);
ut.expect(l_result,'Returns a varchar2 eclosed in quotes').to_equal(l_expected);

end;

procedure to_string_big_blob is
l_text clob := lpad('A test char',32767,'1')||lpad('1',32767,'1');
l_value blob;
Expand Down Expand Up @@ -162,7 +162,7 @@ end;]' using p_expected_list;
ut.EXPECT(l_result).to_be_like('%'||ut3.ut_utils.gc_more_data_string);

end;

procedure to_string_big_clob is
l_value clob := lpad('A test char',32767,'1')||lpad('1',32767,'1');
l_result varchar2(32767);
Expand All @@ -173,7 +173,7 @@ end;]' using p_expected_list;
ut.EXPECT(length(l_result)).to_equal(ut3.ut_utils.gc_max_output_string_length);
ut.EXPECT(l_result).to_be_like('%'||ut3.ut_utils.gc_more_data_string);
end;

procedure to_string_big_number is
l_value number := 1234567890123456789012345678901234567890;
l_expected varchar2(100) := '1234567890123456789012345678901234567890';
Expand All @@ -184,7 +184,7 @@ end;]' using p_expected_list;
--Assert
ut.expect(l_result).TO_equal(l_expected);
end;

procedure to_string_big_varchar2 is
l_value varchar2(32767) := lpad('A test char',32767,'1');
l_result varchar2(32767);
Expand All @@ -205,20 +205,20 @@ end;]' using p_expected_list;
--Act
select substr(value, 1, 1) into l_delimiter from nls_session_parameters t where t.parameter = 'NLS_NUMERIC_CHARACTERS';
l_expected := l_delimiter||'123456789012345678901234567890123456789';

l_result := ut3.ut_utils.to_String(l_value);

--Assert
ut.expect(l_result).TO_equal(l_expected);

end;

procedure test_table_to_clob is
procedure exec_table_to_clob(a_list ut3.ut_varchar2_list, a_delimiter varchar2, a_expected clob) is
l_result clob;
begin
l_result := ut3.ut_utils.table_to_clob(a_list, a_delimiter);

ut.expect(l_result).to_equal(a_expected, a_nulls_are_equal => true);
end;
begin
Expand Down Expand Up @@ -254,7 +254,7 @@ end;]' using p_expected_list;
select value into gv_nls_value from nls_session_parameters where parameter = 'NLS_DATE_LANGUAGE';
execute immediate 'alter session set nls_date_language=ENGLISH';
execute immediate 'create or replace package tst_chars as
-- 2) Status of the process = �PE� with no linked data
-- 2) Status of the process = 😡PE😡 with no linked data
end;';
execute immediate 'alter session set nls_date_language=RUSSIAN';

Expand All @@ -265,12 +265,12 @@ end;';
execute immediate 'alter session set nls_date_language='||gv_nls_value;
execute immediate 'drop package tst_chars';
end;

procedure test_clob_to_table_multibyte is
l_varchar2_byte_limit integer := 32767;
l_workaround_byte_limit integer := 8191;
l_singlebyte_string_max_size varchar2(32767 char) := rpad('x',l_varchar2_byte_limit,'x');
l_twobyte_character char(1 char) := '';
l_twobyte_character char(1 char) := '😁';
l_clob_multibyte clob := l_twobyte_character||l_singlebyte_string_max_size; --here we have 32769(2+32767) bytes and 32768 chars
l_expected ut3.ut_varchar2_list := ut3.ut_varchar2_list();
l_result ut3.ut_varchar2_list;
Expand Down