Permalink
Browse files

A java.sql.Statement must only throw an java.sql.SQLException.

  • Loading branch information...
1 parent 857aae8 commit 8149fb64a8b5f3f427e91f94582a899ef930a5e1 @avinashreddy committed Sep 19, 2011
Showing with 12 additions and 4 deletions.
  1. +12 −4 src/test/java/org/sqlrecorder/integration/SqlRecorderIntegrationTest.java
@@ -17,14 +17,16 @@
import java.sql.Statement;
import java.util.List;
-import com.google.common.io.Files;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.sqlrecorder.util.TestUtils;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import com.google.common.io.Files;
+
//TODO : Refactor the code to validate lines in the log files. It uses the same code in all the tests.
@Test
@@ -39,8 +41,9 @@
@BeforeClass
public void setUp() throws SQLException, ClassNotFoundException {
TestUtils.deRegisterAllDrivers();
- System.setProperty("sqlrecorder.config.location", "classpath:sampleconfig.xml");
- Class.forName("org.sqlrecorder.SqlRecorder");
+ //System.setProperty("sqlrecorder.config.location", "classpath:sampleconfig.xml");
+ //Class.forName("org.sqlrecorder.SqlRecorder");
+ ClassPathXmlApplicationContext c = new ClassPathXmlApplicationContext("sampleconfig.xml");
connection = DriverManager.getConnection(jdbcUrl, username, password);
Statement s = connection.createStatement();
@@ -203,7 +206,12 @@ public void storedProcedureWithParam() throws SQLException {
String firstQuery = linesAfterExecution.get(zeroIndex);
assertThat(firstQuery, containsString(expectedQuery));
}
-
+
+ @Test(expectedExceptions = SQLException.class)
+ public void runSQLWithErrors() throws SQLException {
+ Statement s = connection.createStatement();
+ s.execute("asdasdas");
+ }
@AfterMethod
public void tearDown() throws SQLException {
connection.close();

0 comments on commit 8149fb6

Please sign in to comment.