changeset 51:9d5c88356247 database-connection-manager

Make unit tests database connection parameters configurable
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 07 Dec 2011 17:24:37 +0100
parents 7d2e2e065cf1
children daf4eab1a51e
files testing/utp_1.1/utp_fcns/utpGetDatabase.m testing/utp_1.1/utp_fcns/utpGetHostname.m testing/utp_1.1/utp_fcns/utpGetPassword.m testing/utp_1.1/utp_fcns/utpGetUsername.m testing/utp_1.1/utp_run.m
diffstat 5 files changed, 27 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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
--- 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
--- 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
--- 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