01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: TestDropTableDerby.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.database.queries;
09:
10: import com.uwyn.rife.database.exceptions.TableNameRequiredException;
11: import com.uwyn.rife.database.exceptions.UnsupportedSqlFeatureException;
12:
13: public class TestDropTableDerby extends TestDropTable {
14: public TestDropTableDerby(String name) {
15: super (name);
16: }
17:
18: public void testInstantiationDerby() {
19: DropTable query = new DropTable(mDerby);
20: assertNotNull(query);
21: try {
22: query.getSql();
23: fail();
24: } catch (TableNameRequiredException e) {
25: assertEquals(e.getQueryName(), "DropTable");
26: }
27: }
28:
29: public void testIncompleteQueryDerby() {
30: DropTable query = new DropTable(mDerby);
31: try {
32: query.getSql();
33: fail();
34: } catch (TableNameRequiredException e) {
35: assertEquals(e.getQueryName(), "DropTable");
36: }
37: query.table("tablename");
38: assertNotNull(query.getSql());
39: }
40:
41: public void testClearDerby() {
42: DropTable query = new DropTable(mDerby);
43: query.table("tablename");
44: assertNotNull(query.getSql());
45: query.clear();
46: try {
47: query.getSql();
48: fail();
49: } catch (TableNameRequiredException e) {
50: assertEquals(e.getQueryName(), "DropTable");
51: }
52: }
53:
54: public void testOneTableDerby() {
55: DropTable query = new DropTable(mDerby);
56: query.table("tabletodrop");
57: assertEquals(query.getSql(), "DROP TABLE tabletodrop");
58: execute(query);
59: }
60:
61: public void testMultipleTablesDerby() {
62: DropTable query = new DropTable(mDerby);
63: query.table("tabletodrop1").table("tabletodrop2").table(
64: "tabletodrop3");
65: try {
66: query.getSql();
67: fail();
68: } catch (UnsupportedSqlFeatureException e) {
69: assertTrue(true);
70: }
71: }
72:
73: public void testCloneDerby() {
74: DropTable query = new DropTable(mDerby);
75: query.table("tabletodrop1");
76: // .table("tabletodrop2")
77: // .table("tabletodrop3");
78: DropTable query_clone = query.clone();
79: assertEquals(query.getSql(), query_clone.getSql());
80: assertTrue(query != query_clone);
81: execute(query_clone);
82: }
83: }
|