001: /*
002: * $Id: TestUnmodifiableResultSet.java,v 1.3 2007/11/13 19:04:01 rwald Exp $
003: * =======================================================================
004: * Copyright (c) 2005 Axion Development Team. All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions
008: * are met:
009: *
010: * 1. Redistributions of source code must retain the above
011: * copyright notice, this list of conditions and the following
012: * disclaimer.
013: *
014: * 2. Redistributions in binary form must reproduce the above copyright
015: * notice, this list of conditions and the following disclaimer in
016: * the documentation and/or other materials provided with the
017: * distribution.
018: *
019: * 3. The names "Tigris", "Axion", nor the names of its contributors may
020: * not be used to endorse or promote products derived from this
021: * software without specific prior written permission.
022: *
023: * 4. Products derived from this software may not be called "Axion", nor
024: * may "Tigris" or "Axion" appear in their names without specific prior
025: * written permission.
026: *
027: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
028: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
029: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
030: * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
031: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
032: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
033: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
034: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
035: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
036: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
037: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
038: * =======================================================================
039: */
040: package org.axiondb.jdbc;
041:
042: import java.io.InputStreamReader;
043: import java.math.BigDecimal;
044: import java.sql.Blob;
045: import java.sql.Date;
046: import java.sql.ResultSet;
047: import java.sql.SQLException;
048: import java.sql.Statement;
049: import java.sql.Time;
050: import java.sql.Timestamp;
051:
052: import junit.framework.Test;
053: import junit.framework.TestSuite;
054:
055: import org.axiondb.AxionException;
056: import org.axiondb.types.LOBType;
057:
058: /**
059: *
060: * @author Jonathan Giron
061: * @version $Revision: 1.3 $
062: */
063: public class TestUnmodifiableResultSet extends AxionTestCaseSupport {
064: /**
065: * @param testName
066: */
067: public TestUnmodifiableResultSet(String testName) {
068: super (testName);
069: }
070:
071: public static Test suite() {
072: return new TestSuite(TestUnmodifiableResultSet.class);
073: }
074:
075: /* (non-Javadoc)
076: * @see junit.framework.TestCase#setUp()
077: */
078: public void setUp() throws Exception {
079: super .setUp();
080:
081: Statement stmt = getConnection()
082: .createStatement(ResultSet.TYPE_FORWARD_ONLY,
083: ResultSet.CONCUR_READ_ONLY);
084: stmt.execute("create table foo (id int, name varchar(50))");
085: stmt.execute("insert into foo values (1, 'my first line')");
086: stmt.execute("insert into foo values (2, 'my second line')");
087:
088: _unmodRs = stmt.executeQuery("select * from foo");
089: }
090:
091: public void testCancelRowUpdates() {
092: try {
093: _unmodRs.cancelRowUpdates();
094: fail("Expected SQLException");
095: } catch (SQLException ignore) {
096: // expected.
097: }
098: }
099:
100: public void testDeleteRow() {
101: try {
102: _unmodRs.deleteRow();
103: fail("Expected SQLException");
104: } catch (SQLException ignore) {
105: // expected.
106: }
107: }
108:
109: public void testInsertRow() {
110: try {
111: _unmodRs.insertRow();
112: fail("Expected SQLException");
113: } catch (SQLException ignore) {
114: // expected.
115: }
116: }
117:
118: public void testMoveToCurrentRow() {
119: try {
120: _unmodRs.moveToCurrentRow();
121: fail("Expected SQLException");
122: } catch (SQLException ignore) {
123: // expected.
124: }
125: }
126:
127: public void testMoveToInsertRow() {
128: try {
129: _unmodRs.moveToInsertRow();
130: fail("Expected SQLException");
131: } catch (SQLException ignore) {
132: // expected.
133: }
134: }
135:
136: public void testUpdateRow() {
137: try {
138: _unmodRs.updateRow();
139: fail("Expected SQLException");
140: } catch (SQLException ignore) {
141: // expected.
142: }
143: }
144:
145: /*
146: * Class under test for void updateNull(int)
147: */
148: public void testUpdateNullint() {
149: try {
150: _unmodRs.updateNull(1);
151: fail("Expected SQLException");
152: } catch (SQLException ignore) {
153: // expected.
154: }
155: }
156:
157: /*
158: * Class under test for void updateByte(int, byte)
159: */
160: public void testUpdateByteintbyte() {
161: try {
162: _unmodRs.updateByte(1, (byte) 0);
163: fail("Expected SQLException");
164: } catch (SQLException ignore) {
165: // expected.
166: }
167: }
168:
169: /*
170: * Class under test for void updateDouble(int, double)
171: */
172: public void testUpdateDoubleintdouble() {
173: try {
174: _unmodRs.updateDouble(1, 0.0);
175: fail("Expected SQLException");
176: } catch (SQLException ignore) {
177: // expected.
178: }
179: }
180:
181: /*
182: * Class under test for void updateFloat(int, float)
183: */
184: public void testUpdateFloatintfloat() {
185: try {
186: _unmodRs.updateFloat(1, 0.0f);
187: fail("Expected SQLException");
188: } catch (SQLException ignore) {
189: // expected.
190: }
191: }
192:
193: /*
194: * Class under test for void updateInt(int, int)
195: */
196: public void testUpdateIntintint() {
197: try {
198: _unmodRs.updateInt(1, 1);
199: fail("Expected SQLException");
200: } catch (SQLException ignore) {
201: // expected.
202: }
203: }
204:
205: /*
206: * Class under test for void updateLong(int, long)
207: */
208: public void testUpdateLongintlong() {
209: try {
210: _unmodRs.updateLong(1, 0L);
211: fail("Expected SQLException");
212: } catch (SQLException ignore) {
213: // expected.
214: }
215: }
216:
217: /*
218: * Class under test for void updateShort(int, short)
219: */
220: public void testUpdateShortintshort() {
221: try {
222: _unmodRs.updateShort(1, (short) 0);
223: fail("Expected SQLException");
224: } catch (SQLException ignore) {
225: // expected.
226: }
227: }
228:
229: /*
230: * Class under test for void updateBoolean(int, boolean)
231: */
232: public void testUpdateBooleanintboolean() {
233: try {
234: _unmodRs.updateBoolean(1, false);
235: fail("Expected SQLException");
236: } catch (SQLException ignore) {
237: // expected.
238: }
239: }
240:
241: /*
242: * Class under test for void updateBytes(int, byte[])
243: */
244: public void testUpdateBytesintbyteArray() {
245: try {
246: _unmodRs.updateBytes(1, new byte[0]);
247: fail("Expected SQLException");
248: } catch (SQLException ignore) {
249: // expected.
250: }
251: }
252:
253: /*
254: * Class under test for void updateAsciiStream(int, InputStream, int)
255: */
256: public void testUpdateAsciiStreamintInputStreamint() {
257: try {
258: _unmodRs.updateAsciiStream(1, System.in, 0);
259: fail("Expected SQLException");
260: } catch (SQLException ignore) {
261: // expected.
262: }
263: }
264:
265: /*
266: * Class under test for void updateBinaryStream(int, InputStream, int)
267: */
268: public void testUpdateBinaryStreamintInputStreamint() {
269: try {
270: _unmodRs.updateBinaryStream(1, System.in, 0);
271: fail("Expected SQLException");
272: } catch (SQLException ignore) {
273: // expected.
274: }
275: }
276:
277: /*
278: * Class under test for void updateCharacterStream(int, Reader, int)
279: */
280: public void testUpdateCharacterStreamintReaderint() {
281: try {
282: _unmodRs.updateCharacterStream(1, new InputStreamReader(
283: System.in), 0);
284: fail("Expected SQLException");
285: } catch (SQLException ignore) {
286: // expected.
287: }
288: }
289:
290: /*
291: * Class under test for void updateObject(int, Object)
292: */
293: public void testUpdateObjectintObject() {
294: try {
295: _unmodRs.updateObject(1, new Object());
296: fail("Expected SQLException");
297: } catch (SQLException ignore) {
298: // expected.
299: }
300:
301: }
302:
303: /*
304: * Class under test for void updateObject(int, Object, int)
305: */
306: public void testUpdateObjectintObjectint() {
307: try {
308: _unmodRs.updateObject(1, new Object(), 0);
309: fail("Expected SQLException");
310: } catch (SQLException ignore) {
311: // expected.
312: }
313: }
314:
315: /*
316: * Class under test for void updateString(int, String)
317: */
318: public void testUpdateStringintString() {
319: try {
320: _unmodRs.updateString(1, "");
321: fail("Expected SQLException");
322: } catch (SQLException ignore) {
323: // expected.
324: }
325: }
326:
327: /*
328: * Class under test for void updateNull(String)
329: */
330: public void testUpdateNullString() {
331: try {
332: _unmodRs.updateNull("id");
333: fail("Expected SQLException");
334: } catch (SQLException ignore) {
335: // expected.
336: }
337: }
338:
339: /*
340: * Class under test for void updateByte(String, byte)
341: */
342: public void testUpdateByteStringbyte() {
343: try {
344: _unmodRs.updateByte("id", (byte) 0);
345: fail("Expected SQLException");
346: } catch (SQLException ignore) {
347: // expected.
348: }
349: }
350:
351: /*
352: * Class under test for void updateDouble(String, double)
353: */
354: public void testUpdateDoubleStringdouble() {
355: try {
356: _unmodRs.updateDouble("id", 0.0);
357: fail("Expected SQLException");
358: } catch (SQLException ignore) {
359: // expected.
360: }
361: }
362:
363: /*
364: * Class under test for void updateFloat(String, float)
365: */
366: public void testUpdateFloatStringfloat() {
367: try {
368: _unmodRs.updateFloat("id", 0.0f);
369: fail("Expected SQLException");
370: } catch (SQLException ignore) {
371: // expected.
372: }
373: }
374:
375: /*
376: * Class under test for void updateInt(String, int)
377: */
378: public void testUpdateIntStringint() {
379: try {
380: _unmodRs.updateInt("id", 0);
381: fail("Expected SQLException");
382: } catch (SQLException ignore) {
383: // expected.
384: }
385: }
386:
387: /*
388: * Class under test for void updateLong(String, long)
389: */
390: public void testUpdateLongStringlong() {
391: try {
392: _unmodRs.updateLong("id", 0L);
393: fail("Expected SQLException");
394: } catch (SQLException ignore) {
395: // expected.
396: }
397: }
398:
399: /*
400: * Class under test for void updateShort(String, short)
401: */
402: public void testUpdateShortStringshort() {
403: try {
404: _unmodRs.updateShort("id", (short) 0);
405: fail("Expected SQLException");
406: } catch (SQLException ignore) {
407: // expected.
408: }
409: }
410:
411: /*
412: * Class under test for void updateBoolean(String, boolean)
413: */
414: public void testUpdateBooleanStringboolean() {
415: try {
416: _unmodRs.updateBoolean("id", false);
417: fail("Expected SQLException");
418: } catch (SQLException ignore) {
419: // expected.
420: }
421: }
422:
423: /*
424: * Class under test for void updateBytes(String, byte[])
425: */
426: public void testUpdateBytesStringbyteArray() {
427: try {
428: _unmodRs.updateBytes("id", new byte[0]);
429: fail("Expected SQLException");
430: } catch (SQLException ignore) {
431: // expected.
432: }
433: }
434:
435: /*
436: * Class under test for void updateBigDecimal(int, BigDecimal)
437: */
438: public void testUpdateBigDecimalintBigDecimal() {
439: try {
440: _unmodRs.updateBigDecimal("id", BigDecimal.valueOf(0L));
441: fail("Expected SQLException");
442: } catch (SQLException ignore) {
443: // expected.
444: }
445: }
446:
447: /*
448: * Class under test for void updateArray(int, Array)
449: */
450: public void testUpdateArrayintArray() {
451: try {
452: _unmodRs.updateArray(1, null);
453: fail("Expected SQLException");
454: } catch (SQLException ignore) {
455: // expected.
456: }
457: }
458:
459: /*
460: * Class under test for void updateBlob(int, Blob)
461: */
462: public void testUpdateBlobintBlob() throws AxionException {
463: try {
464: _unmodRs.updateBlob(1, (Blob) null);
465: fail("Expected SQLException");
466: } catch (SQLException ignore) {
467: // expected.
468: }
469: }
470:
471: /*
472: * Class under test for void updateClob(int, Clob)
473: */
474: public void testUpdateClobintClob() throws AxionException {
475: try {
476: _unmodRs.updateClob("id", _lobType.toClob("foo"));
477: fail("Expected SQLException");
478: } catch (SQLException ignore) {
479: // expected.
480: }
481: }
482:
483: /*
484: * Class under test for void updateDate(int, Date)
485: */
486: public void testUpdateDateintDate() {
487: try {
488: _unmodRs.updateDate(1, new Date(0L));
489: fail("Expected SQLException");
490: } catch (SQLException ignore) {
491: // expected.
492: }
493: }
494:
495: /*
496: * Class under test for void updateRef(int, Ref)
497: */
498: public void testUpdateRefintRef() {
499: try {
500: _unmodRs.updateRef(1, null);
501: fail("Expected SQLException");
502: } catch (SQLException ignore) {
503: // expected.
504: }
505: }
506:
507: /*
508: * Class under test for void updateTime(int, Time)
509: */
510: public void testUpdateTimeintTime() {
511: try {
512: _unmodRs.updateTime(1, new Time(0L));
513: fail("Expected SQLException");
514: } catch (SQLException ignore) {
515: // expected.
516: }
517: }
518:
519: /*
520: * Class under test for void updateTimestamp(int, Timestamp)
521: */
522: public void testUpdateTimestampintTimestamp() {
523: try {
524: _unmodRs.updateTimestamp(1, new Timestamp(0L));
525: fail("Expected SQLException");
526: } catch (SQLException ignore) {
527: // expected.
528: }
529: }
530:
531: /*
532: * Class under test for void updateAsciiStream(String, InputStream, int)
533: */
534: public void testUpdateAsciiStreamStringInputStreamint() {
535: try {
536: _unmodRs.updateAsciiStream("foo", System.in, 0);
537: fail("Expected SQLException");
538: } catch (SQLException ignore) {
539: // expected.
540: }
541: }
542:
543: /*
544: * Class under test for void updateBinaryStream(String, InputStream, int)
545: */
546: public void testUpdateBinaryStreamStringInputStreamint() {
547: try {
548: _unmodRs.updateBinaryStream("foo", System.in, 0);
549: fail("Expected SQLException");
550: } catch (SQLException ignore) {
551: // expected.
552: }
553: }
554:
555: /*
556: * Class under test for void updateCharacterStream(String, Reader, int)
557: */
558: public void testUpdateCharacterStreamStringReaderint() {
559: try {
560: _unmodRs.updateCharacterStream("foo",
561: new InputStreamReader(System.in), 0);
562: fail("Expected SQLException");
563: } catch (SQLException ignore) {
564: // expected.
565: }
566: }
567:
568: /*
569: * Class under test for void updateObject(String, Object)
570: */
571: public void testUpdateObjectStringObject() {
572: try {
573: _unmodRs.updateObject("foo", new Object());
574: fail("Expected SQLException");
575: } catch (SQLException ignore) {
576: // expected.
577: }
578: }
579:
580: /*
581: * Class under test for void updateObject(String, Object, int)
582: */
583: public void testUpdateObjectStringObjectint() {
584: try {
585: _unmodRs.updateObject("foo", new Object(), 0);
586: fail("Expected SQLException");
587: } catch (SQLException ignore) {
588: // expected.
589: }
590: }
591:
592: /*
593: * Class under test for void updateString(String, String)
594: */
595: public void testUpdateStringStringString() {
596: try {
597: _unmodRs.updateString("foo", "");
598: fail("Expected SQLException");
599: } catch (SQLException ignore) {
600: // expected.
601: }
602: }
603:
604: /*
605: * Class under test for void updateBigDecimal(String, BigDecimal)
606: */
607: public void testUpdateBigDecimalStringBigDecimal() {
608: try {
609: _unmodRs.updateBigDecimal("foo", BigDecimal.valueOf(0L));
610: fail("Expected SQLException");
611: } catch (SQLException ignore) {
612: // expected.
613: }
614: }
615:
616: /*
617: * Class under test for void updateArray(String, Array)
618: */
619: public void testUpdateArrayStringArray() {
620: try {
621: _unmodRs.updateArray("foo", null);
622: fail("Expected SQLException");
623: } catch (SQLException ignore) {
624: // expected.
625: }
626: }
627:
628: /*
629: * Class under test for void updateBlob(String, Blob)
630: */
631: public void testUpdateBlobStringBlob() throws AxionException {
632: try {
633: _unmodRs.updateBlob("foo", (Blob) null);
634: fail("Expected SQLException");
635: } catch (SQLException ignore) {
636: // expected.
637: }
638: }
639:
640: /*
641: * Class under test for void updateClob(String, Clob)
642: */
643: public void testUpdateClobStringClob() throws AxionException {
644: try {
645: _unmodRs.updateClob("foo", _lobType.toClob("foo"));
646: fail("Expected SQLException");
647: } catch (SQLException ignore) {
648: // expected.
649: }
650: }
651:
652: /*
653: * Class under test for void updateDate(String, Date)
654: */
655: public void testUpdateDateStringDate() {
656: try {
657: _unmodRs.updateDate("foo", new Date(0L));
658: fail("Expected SQLException");
659: } catch (SQLException ignore) {
660: // expected.
661: }
662: }
663:
664: /*
665: * Class under test for void updateRef(String, Ref)
666: */
667: public void testUpdateRefStringRef() {
668: try {
669: _unmodRs.updateRef("foo", null);
670: fail("Expected SQLException");
671: } catch (SQLException ignore) {
672: // expected.
673: }
674: }
675:
676: /*
677: * Class under test for void updateTime(String, Time)
678: */
679: public void testUpdateTimeStringTime() {
680: try {
681: _unmodRs.updateTime("foo", new Time(0L));
682: fail("Expected SQLException");
683: } catch (SQLException ignore) {
684: // expected.
685: }
686: }
687:
688: /*
689: * Class under test for void updateTimestamp(String, Timestamp)
690: */
691: public void testUpdateTimestampStringTimestamp() {
692: try {
693: _unmodRs.updateTimestamp("foo", new Timestamp(0L));
694: fail("Expected SQLException");
695: } catch (SQLException ignore) {
696: // expected.
697: }
698: }
699:
700: private LOBType _lobType = new LOBType();
701: private ResultSet _unmodRs;
702: }
|