# HG changeset patch # User Daniele Nicolodi # Date 1323275077 -3600 # Node ID 9d5c8835624734944995e3e898b670517f877924 # Parent 7d2e2e065cf1cf2401756b181667e9b07682080d Make unit tests database connection parameters configurable diff -r 7d2e2e065cf1 -r 9d5c88356247 testing/utp_1.1/utp_fcns/utpGetDatabase.m --- a/testing/utp_1.1/utp_fcns/utpGetDatabase.m Wed Dec 07 17:24:37 2011 +0100 +++ b/testing/utp_1.1/utp_fcns/utpGetDatabase.m Wed Dec 07 17:24:37 2011 +0100 @@ -12,7 +12,6 @@ function database = utpGetDatabase() -% database = 'an other db name'; - database = 'ltpda_test'; + database = getappdata(0, 'LTPDAUtpRepositoryDatabase'); end diff -r 7d2e2e065cf1 -r 9d5c88356247 testing/utp_1.1/utp_fcns/utpGetHostname.m --- a/testing/utp_1.1/utp_fcns/utpGetHostname.m Wed Dec 07 17:24:37 2011 +0100 +++ b/testing/utp_1.1/utp_fcns/utpGetHostname.m Wed Dec 07 17:24:37 2011 +0100 @@ -12,7 +12,6 @@ function hostname = utpGetHostname() -% hostname = 'localhost'; - hostname = '130.75.117.67'; + hostname = getappdata(0, 'LTPDAUtpRepositoryHostname'); end diff -r 7d2e2e065cf1 -r 9d5c88356247 testing/utp_1.1/utp_fcns/utpGetPassword.m --- a/testing/utp_1.1/utp_fcns/utpGetPassword.m Wed Dec 07 17:24:37 2011 +0100 +++ b/testing/utp_1.1/utp_fcns/utpGetPassword.m Wed Dec 07 17:24:37 2011 +0100 @@ -12,9 +12,6 @@ function password = utpGetPassword() - password = getappdata(0, 'LTPDARepoPassword'); - if isempty(password) - password = 'a1b2c3d4'; - end + password = getappdata(0, 'LTPDAUtpRepositoryPassword'); end diff -r 7d2e2e065cf1 -r 9d5c88356247 testing/utp_1.1/utp_fcns/utpGetUsername.m --- a/testing/utp_1.1/utp_fcns/utpGetUsername.m Wed Dec 07 17:24:37 2011 +0100 +++ b/testing/utp_1.1/utp_fcns/utpGetUsername.m Wed Dec 07 17:24:37 2011 +0100 @@ -12,9 +12,6 @@ function username = utpGetUsername() - username = getappdata(0, 'LTPDARepoUsername'); - if isempty(username) - username = 'tester'; - end + username = getappdata(0, 'LTPDAUtpRepositoryUsername'); end diff -r 7d2e2e065cf1 -r 9d5c88356247 testing/utp_1.1/utp_run.m --- a/testing/utp_1.1/utp_run.m Wed Dec 07 17:24:37 2011 +0100 +++ b/testing/utp_1.1/utp_run.m Wed Dec 07 17:24:37 2011 +0100 @@ -45,6 +45,16 @@ skipTests = pl.find('skip tests', ''); tests = pl.find('tests', ''); noRepository = pl.find('no repository', false); + + hostname = pl.find('hostname', '130.75.117.67'); + database = pl.find('database', 'ltpda_test'); + username = pl.find('username', 'tester'); + password = pl.find('password', 'a1b2c3d4'); + + setappdata(0, 'LTPDAUtpRepositoryHostname', hostname); + setappdata(0, 'LTPDAUtpRepositoryDatabase', database); + setappdata(0, 'LTPDAUtpRepositoryUsername', username); + setappdata(0, 'LTPDAUtpRepositoryPassword', password); if ~isempty(rest) && ~isempty(tests) tests = [reshape(cellstr(tests), 1, []), reshape(rest, 1, [])]; @@ -142,7 +152,7 @@ results = []; for jj=1:length(utps) try - results = [results eval(utps{jj})]; + results = [results eval(utps{jj})] catch ex % report the error failure in running the UTP stack.name = 'xx'; @@ -164,12 +174,24 @@ catch ex % restore original path path(oldpath); + % remove appdata + rmappdata(0, 'LTPDAUtpRepositoryHostname'); + rmappdata(0, 'LTPDAUtpRepositoryDatabase'); + rmappdata(0, 'LTPDAUtpRepositoryUsername'); + rmappdata(0, 'LTPDAUtpRepositoryPassword'); + % propagate exception rethrow(ex); end % restore original path path(oldpath); + % remove appdata + rmappdata(0, 'LTPDAUtpRepositoryHostname'); + rmappdata(0, 'LTPDAUtpRepositoryDatabase'); + rmappdata(0, 'LTPDAUtpRepositoryUsername'); + rmappdata(0, 'LTPDAUtpRepositoryPassword'); + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % FUNCTION: addUtpTest