01: /*-------------------------------------------------------------------------
02: *
03: * Copyright (c) 2007, PostgreSQL Global Development Group
04: *
05: * IDENTIFICATION
06: * $PostgreSQL: pgjdbc/org/postgresql/test/jdbc4/LOBTest.java,v 1.1 2007/02/19 17:21:13 jurka Exp $
07: *
08: *-------------------------------------------------------------------------
09: */
10: package org.postgresql.test.jdbc4;
11:
12: import java.sql.*;
13: import junit.framework.TestCase;
14: import org.postgresql.test.TestUtil;
15:
16: public class LOBTest extends TestCase {
17:
18: private Connection _conn;
19:
20: public LOBTest(String name) {
21: super (name);
22: }
23:
24: protected void setUp() throws Exception {
25: _conn = TestUtil.openDB();
26: Statement stmt = _conn.createStatement();
27: stmt.execute("CREATE TEMP TABLE lotest(lo oid)");
28: stmt.execute("INSERT INTO lotest VALUES(lo_creat(-1))");
29: stmt.close();
30: }
31:
32: protected void tearDown() throws SQLException {
33: Statement stmt = _conn.createStatement();
34: stmt.execute("DROP TABLE lotest");
35: stmt.close();
36: TestUtil.closeDB(_conn);
37: }
38:
39: public void testFree() throws SQLException {
40: _conn.setAutoCommit(false);
41: Statement stmt = _conn.createStatement();
42: ResultSet rs = stmt.executeQuery("SELECT lo FROM lotest");
43: assertTrue(rs.next());
44:
45: Blob blob = rs.getBlob(1);
46: blob.free();
47: try {
48: blob.length();
49: fail("Should have thrown an Exception because it was freed.");
50: } catch (SQLException sqle) {
51: }
52: }
53:
54: }
|