java - how to Return Exceptions from API methods using Powemock-easymcok -


i quite beginner easymock/powermock if can me following problem. have following daoimpl class in connecting database , performing search operation.

public  list<shoppinglist> getshoppinglist(department department)  throws shoppinglistdaoexception {          shopping_list_qry1= "{call ec_list_package.get_shopping_lists_id_order(?,?,?,?)}";         connection =null;         resultset resultset =null;         callablestatement  callablestatment = null;         list <shoppinglist> shoppinglist = new arraylist<shoppinglist>();                 datasource ds = null;            try {                         if("true".equals(junit)){             connection = getdatasource(true);             }else {                 ds = getdatasource();                 connection = ds.getconnection();             }                 callablestatment = connection.preparecall(shopping_list_qry1);               callablestatment.setstring(1, department.getdistributornumber());             callablestatment.setstring(2, department.getcustomernumber());             callablestatment.setstring(3, department.getdepartmentnumber());                 callablestatment.registeroutparameter(4, oracletypes.cursor);             callablestatment.execute();             resultset= (resultset) callablestatment.getobject(4);              while(resultset.next()) {                            .......some code here.....                            }                    } catch (sqlexception e) {                       e.printstacktrace();             throw new shoppinglistdaoexception(e);         } catch (exception e) {                      e.printstacktrace();             throw new shoppinglistdaoexception(e);         }finally{             try {                 if(resultset!=null)                     resultset.close();                 if(callablestatment!=null)                     callablestatment.close();                 if(connection!=null)                     connection.close();             } catch (sqlexception e) {                               e.printstacktrace();                         }        }                    return shoppinglist;     } 
  1. now there way can return exception object callablestatement.execute() method using mocking improve code coverage.


Comments