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: TestSequenceValueMckoi.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.SequenceNameRequiredException;
11: import com.uwyn.rife.database.exceptions.SequenceOperationRequiredException;
12: import com.uwyn.rife.database.exceptions.UnsupportedSqlFeatureException;
13:
14: public class TestSequenceValueMckoi extends TestSequenceValue {
15: public TestSequenceValueMckoi(String name) {
16: super (name);
17: }
18:
19: public void testInstantiationMckoi() {
20: SequenceValue query = new SequenceValue(mMckoi);
21: assertNotNull(query);
22: try {
23: query.getSql();
24: fail();
25: } catch (SequenceNameRequiredException e) {
26: assertEquals(e.getQueryName(), "SequenceValue");
27: }
28: }
29:
30: public void testInvalidMckoi() {
31: SequenceValue query = new SequenceValue(mMckoi);
32: try {
33: query.getSql();
34: fail();
35: } catch (SequenceNameRequiredException e) {
36: assertEquals(e.getQueryName(), "SequenceValue");
37: }
38: query.name("sequencename");
39: try {
40: query.getSql();
41: fail();
42: } catch (SequenceOperationRequiredException e) {
43: assertEquals(e.getQueryName(), "SequenceValue");
44: }
45: query.clear();
46: query.next();
47: try {
48: query.getSql();
49: fail();
50: } catch (SequenceNameRequiredException e) {
51: assertEquals(e.getQueryName(), "SequenceValue");
52: }
53: query.clear();
54: }
55:
56: public void testClearMckoi() {
57: SequenceValue query = new SequenceValue(mMckoi);
58: query.name("sequencename").next();
59: assertNotNull(query.getSql());
60: query.clear();
61: try {
62: query.getSql();
63: fail();
64: } catch (SequenceNameRequiredException e) {
65: assertEquals(e.getQueryName(), "SequenceValue");
66: }
67: }
68:
69: public void testNextMckoi() {
70: SequenceValue query = new SequenceValue(mMckoi);
71: query.name("sequencename").next();
72: assertEquals(query.getSql(), "SELECT nextval('sequencename')");
73: assertTrue(execute(mMckoi, query) >= 0);
74: }
75:
76: public void testCurrentMckoi() {
77: SequenceValue query = new SequenceValue(mMckoi);
78: query.name("sequencename").current();
79: try {
80: query.getSql();
81: fail();
82: } catch (UnsupportedSqlFeatureException e) {
83: assertTrue(true);
84: }
85: }
86:
87: public void testCloneMckoi() {
88: SequenceValue query = new SequenceValue(mMckoi);
89: query.name("sequencename").next();
90: SequenceValue query_clone = query.clone();
91: assertEquals(query.getSql(), query_clone.getSql());
92: assertTrue(query != query_clone);
93: assertTrue(execute(mMckoi, query_clone) >= 0);
94: }
95: }
|