1
2
3
4 package org.melati.poem.test.throwing;
5
6 import java.sql.Connection;
7 import java.sql.PreparedStatement;
8
9 import org.melati.poem.Database;
10 import org.melati.poem.PoemDatabaseFactory;
11 import org.melati.poem.PreparedSQLSeriousPoemException;
12 import org.melati.poem.PreparedStatementFactory;
13 import org.melati.poem.SQLPoemException;
14 import org.melati.poem.dbms.test.sql.Thrower;
15
16
17
18
19
20
21 public class PreparedStatementFactoryTest extends
22 org.melati.poem.test.PreparedStatementFactoryTest {
23
24
25
26
27 public PreparedStatementFactoryTest(String name) {
28 super(name);
29 }
30
31 protected void setUp() throws Exception {
32 PoemDatabaseFactory.removeDatabase(getDatabaseName());
33 super.setUp();
34 assertEquals("org.melati.poem.dbms.test.HsqldbThrower",getDb().getDbms().getClass().getName());
35 }
36 protected void tearDown() throws Exception {
37 try {
38 super.tearDown();
39 } finally {
40 PoemDatabaseFactory.removeDatabase(getDatabaseName());
41 }
42 }
43
44
45 public Database getDatabase(String name) {
46 maxTrans = 8;
47 Database db = PoemDatabaseFactory.getDatabase(name,
48 "jdbc:hsqldb:mem:" + name,
49 "sa",
50 "",
51 "org.melati.poem.PoemDatabase",
52 "org.melati.poem.dbms.test.HsqldbThrower",
53 false,
54 false,
55 false, maxTrans);
56 return db;
57 }
58
59 public void testGet() {
60 super.testGet();
61 }
62
63 public void testPreparedStatement() throws Exception {
64 Thrower.startThrowing(Connection.class, "prepareStatement");
65 try {
66 super.testPreparedStatement();
67 fail("Should have bombed");
68 } catch (SQLPoemException e) {
69 assertEquals("Connection bombed", e.innermostException().getMessage());
70 }
71 Thrower.stopThrowing(Connection.class, "prepareStatement");
72 }
73
74 public void testPreparedStatementFactory() {
75
76 }
77
78 public void testPreparedStatementPoemTransaction() {
79
80 }
81
82 public void testResultSet() throws Exception {
83 PreparedStatementFactory it = new PreparedStatementFactory(getDb(),
84 getDb().getUserTable().selectionSQL(null,null,null,true,false));
85 try {
86 Thrower.startThrowing(PreparedStatement.class, "executeQuery");
87 it.resultSet();
88 fail("Should have bombed");
89 } catch (PreparedSQLSeriousPoemException e) {
90 assertEquals("PreparedStatement bombed", e.innermostException().getMessage());
91 }
92 Thrower.stopThrowing(PreparedStatement.class, "executeQuery");
93 }
94
95 }
96