~ubuntu-branches/ubuntu/oneiric/mysql-connector-java/oneiric

« back to all changes in this revision

Viewing changes to src/testsuite/simple/BlobTest.java

  • Committer: Bazaar Package Importer
  • Author(s): Marcus Better
  • Date: 2006-12-29 13:29:04 UTC
  • mfrom: (1.1.3 upstream) (3.1.1 etch)
  • Revision ID: james.westby@ubuntu.com-20061229132904-uj7edcmwgtuxh6li
Tags: 5.0.4+dfsg-2
Corrected the symlink `/usr/share/java/mysql.jar'. Thanks to Javier
Kohen. (Closes: #404858)

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
import java.io.FileOutputStream;
35
35
import java.io.InputStream;
36
36
 
 
37
import java.sql.Connection;
37
38
import java.sql.ResultSet;
38
39
import java.sql.SQLException;
39
40
import java.util.Properties;
42
43
 * Tests BLOB functionality in the driver.
43
44
 * 
44
45
 * @author Mark Matthews
45
 
 * @version $Id: BlobTest.java 3726 2005-05-19 15:52:24Z mmatthews $
 
46
 * @version $Id: BlobTest.java 4312 2005-09-26 19:31:34Z mmatthews $
46
47
 */
47
48
public class BlobTest extends BaseTestCase {
48
49
        // ~ Static fields/initializers
116
117
                }
117
118
        }
118
119
 
 
120
        public void testByteStreamInsert() throws Exception {
 
121
                testByteStreamInsert(this.conn);
 
122
        }
119
123
        /**
120
124
         * Tests inserting blob data as a stream
121
125
         * 
122
126
         * @throws Exception
123
127
         *             if an error occurs
124
128
         */
125
 
        public void testByteStreamInsert() throws Exception {
 
129
        private void testByteStreamInsert(Connection c) throws Exception {
126
130
                BufferedInputStream bIn = new BufferedInputStream(new FileInputStream(
127
131
                                testBlobFile));
128
 
                this.pstmt = this.conn
 
132
                this.pstmt = c
129
133
                                .prepareStatement("INSERT INTO BLOBTEST(blobdata) VALUES (?)");
130
134
                this.pstmt.setBinaryStream(1, bIn, (int) testBlobFile.length());
131
135
                this.pstmt.execute();
134
138
                doRetrieval();
135
139
        }
136
140
 
137
 
        /**
138
 
         * Tests multi-packet functionality with NIO layer.
139
 
         * 
140
 
         * @throws Exception
141
 
         *             if an unexpected error occurs.
142
 
         */
143
 
        public void testBytesInsertNewIo() throws Exception {
144
 
                Properties props = new Properties();
145
 
                props.setProperty("useNewIO", "true");
146
 
 
147
 
                this.conn = getConnectionWithProps(props);
148
 
 
149
 
                testByteStreamInsert();
150
 
        }
151
 
 
152
141
        private boolean checkBlob(byte[] retrBytes) throws Exception {
153
142
                boolean passed = false;
154
143
                BufferedInputStream bIn = new BufferedInputStream(new FileInputStream(