You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2020/02/08 13:31:08 UTC

[GitHub] [incubator-dolphinscheduler] Jave-Chen commented on issue #1909: add ScriptRunnerTest.java unit test

Jave-Chen commented on issue #1909: add ScriptRunnerTest.java unit test
URL: https://github.com/apache/incubator-dolphinscheduler/pull/1909#issuecomment-583736846
 
 
   ```
   try {
       Connection conn = Mockito.mock(Connection.class);
       Mockito.when(conn.getAutoCommit()).thenReturn(true);
       PreparedStatement st = Mockito.mock(PreparedStatement.class);
       Mockito.when(conn.createStatement()).thenReturn(st);
       ResultSet rs = Mockito.mock(ResultSet.class);
       Mockito.when(st.getResultSet()).thenReturn(rs);
       ResultSetMetaData md = Mockito.mock(ResultSetMetaData.class);
       Mockito.when(rs.getMetaData()).thenReturn(md);
       Mockito.when(md.getColumnCount()).thenReturn(1);
       Mockito.when(rs.next()).thenReturn(true, false);
       ScriptRunner s = new ScriptRunner(conn, true, true);
       s.runScript(new StringReader("select 1;"), "test_db");
       Mockito.verify(md).getColumnLabel(0);
   } catch(Exception e) {
       Assert.assertNotNull(e);
   }
   ```
   how about encapsulate as a method ?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services