Created
May 24, 2011 21:03
-
-
Save ran488/989685 to your computer and use it in GitHub Desktop.
Groovy and JUnit testing for PL/SQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.XXXXX.XXX.plsql | |
import static org.junit.Assert.* | |
import org.junit.After | |
import org.junit.Before | |
import org.junit.Test | |
import groovy.sql.Sql | |
class XXXWriteApplLogTest { | |
Sql sql | |
@Before | |
public void setUp() throws Exception { | |
def db = [url:'jdbc:oracle:thin:@XXXdev2.XXXXX.com:1521:XXXd10g', | |
user:'XXX', | |
password:'XXX', | |
driver:'oracle.jdbc.driver.OracleDriver'] | |
sql = Sql.newInstance(db.url, db.user, db.password, db.driver) | |
} | |
@After | |
public void tearDown() throws Exception { | |
sql.call "DELETE FROM XXX.APPL_LOG WHERE SOURCE = 'UT' and CORRELATION_ID = 'UT-101'" | |
} | |
@Test | |
public void testWriteApplLog() { | |
println "Calling procedure..." | |
def plsqlCall = "{ call XXX.WRITE_APPL_LOG(?,?,?,?) }" | |
def params = [ 'UT','INFO','Test message from automated test suite','UT-101' ] | |
sql.call(plsqlCall, params) | |
def verify = "SELECT * FROM XXX.APPL_LOG WHERE SOURCE = 'UT' and CORRELATION_ID = 'UT-101'" | |
def results = sql.rows(verify) | |
results.each { r -> println r } | |
assertEquals(results.size, 1) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment