|
9 | 9 | //-------------------------------------- |
10 | 10 | package org.sqlite; |
11 | 11 |
|
12 | | -import static org.junit.Assert.*; |
| 12 | +import static org.junit.Assert.assertEquals; |
| 13 | +import static org.junit.Assert.assertFalse; |
| 14 | +import static org.junit.Assert.assertNull; |
| 15 | +import static org.junit.Assert.assertTrue; |
13 | 16 |
|
14 | 17 | import java.sql.Connection; |
15 | 18 | import java.sql.DriverManager; |
|
19 | 22 | import java.sql.Statement; |
20 | 23 | import java.util.Date; |
21 | 24 |
|
22 | | -import org.sqlite.date.FastDateFormat; |
23 | | - |
24 | | -import org.junit.BeforeClass; |
25 | 25 | import org.junit.Test; |
| 26 | +import org.sqlite.date.FastDateFormat; |
26 | 27 |
|
27 | 28 | public class QueryTest |
28 | 29 | { |
@@ -103,6 +104,49 @@ public void dateTimeTest() throws Exception { |
103 | 104 | stmt.setDate(1, new java.sql.Date(now.getTime())); |
104 | 105 | } |
105 | 106 |
|
| 107 | + @Test |
| 108 | + public void notEmptyBlob() throws Exception { |
| 109 | + Connection conn = getConnection(); |
| 110 | + |
| 111 | + conn.createStatement().execute("create table sample (b blob not null)"); |
| 112 | + |
| 113 | + conn.createStatement().execute("insert into sample values(zeroblob(5))"); |
| 114 | + |
| 115 | + ResultSet rs = conn.createStatement().executeQuery("select * from sample"); |
| 116 | + assertTrue(rs.next()); |
| 117 | + assertEquals(5, rs.getBytes(1).length); |
| 118 | + assertFalse(rs.wasNull()); |
| 119 | + } |
| 120 | + |
| 121 | + @Test |
| 122 | + public void emptyBlob() throws Exception { |
| 123 | + Connection conn = getConnection(); |
| 124 | + |
| 125 | + conn.createStatement().execute("create table sample (b blob null)"); |
| 126 | + |
| 127 | + conn.createStatement().execute("insert into sample values(zeroblob(0))"); |
| 128 | + |
| 129 | + ResultSet rs = conn.createStatement().executeQuery("select * from sample"); |
| 130 | + assertTrue(rs.next()); |
| 131 | + assertEquals(0, rs.getBytes(1).length); |
| 132 | + assertFalse(rs.wasNull()); |
| 133 | + } |
| 134 | + |
| 135 | + @Test |
| 136 | + public void nullBlob() throws Exception { |
| 137 | + Connection conn = getConnection(); |
| 138 | + |
| 139 | + conn.createStatement().execute("create table sample (b blob null)"); |
| 140 | + |
| 141 | + conn.createStatement().execute("insert into sample values(null)"); |
| 142 | + |
| 143 | + ResultSet rs = conn.createStatement().executeQuery("select * from sample"); |
| 144 | + assertTrue(rs.next()); |
| 145 | + assertNull(rs.getBytes(1)); |
| 146 | + assertTrue(rs.wasNull()); |
| 147 | + } |
| 148 | + |
| 149 | + |
106 | 150 | @Test |
107 | 151 | public void viewTest() throws Exception { |
108 | 152 | Connection conn = getConnection(); |
|
0 commit comments