powermock method invocation exception

`public class DBConnection {

public static Connection getConnection(String dataSource){

Connection con = null;

try

{

try {

ClassPathResource resource = new ClassPathResource("application-config.xml");

XmlBeanFactory factory = new XmlBeanFactory(resource);

DataSource ds = null;

ds =(DataSource)factory.getBean(dataSource);

con = ds.getConnection();

}catch (SQLException se){

se.printStackTrace();

System.out.println("SQL Exception in getConnection "+se);

}

public class DeactivateRenewalExpired {

private static Connection db2Con = null;

private MailBean mail = new MailBean();

public static void main(String[] args)throws SQLException {

System.out.println("dfdfdf");

try{

Environment.PROPERTIES_FILE = args [0];

db2Con = DBConnection.getConnection(Environment.DATASOURCE_DB2);

DeactivateRenewalExpired renewal = new DeactivateRenewalExpired();

renewal.deactivate();

}`

im trying to write junit for main method and init im trying to mock DBConnection using powermock , im getting exception coz getConnection is a...

Read More »

By: StackOverFlow - 5 days ago

Related Posts