lundi 26 octobre 2020

Mock new Object using Mockito only

I have a method code like this in a class

public List<Auth_token> getAuthToken(String User) throws SQLException {
        List<Auth_token> usersList = new ArrayList<Auth_token>();
        Connection connection = null;
        PreparedStatement ps = null;
        ResultSet rset = null;
        try {

            OracleDataSource dataSource = new OracleDataSource();
            dataSource.setURL("blah blah");
            dataSource.setUser("blah");

            //LOGGER.log(Level.INFO,"username +: "+config.getUsername());
            dataSource.setPassword("blah");

            Connection conn = dataSource.getConnection();
            String query = "blah query";
//more code
}

I need to mock oracle datasource using mockito only. I know how to do using power mockito but i have to do this using mockito only. Please help me.

Aucun commentaire:

Enregistrer un commentaire