MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QueryNullTest.java
1 /*
2 Copyright 2010 Sun Microsystems, Inc.
3 All rights reserved. Use is subject to license terms.
4 
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; version 2 of the License.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 package testsuite.clusterj;
20 
21 import testsuite.clusterj.model.AllPrimitives;
22 
23 import com.mysql.clusterj.ClusterJUserException;
24 
31 public class QueryNullTest extends AbstractQueryTest {
32  /*
33  drop table if exists allprimitives;
34  create table allprimitives (
35  id int not null primary key,
36 
37  int_not_null_hash int not null,
38  int_not_null_btree int not null,
39  int_not_null_both int not null,
40  int_not_null_none int not null,
41  int_null_hash int,
42  int_null_btree int,
43  int_null_both int,
44  int_null_none int,
45 
46  byte_not_null_hash tinyint not null,
47  byte_not_null_btree tinyint not null,
48  byte_not_null_both tinyint not null,
49  byte_not_null_none tinyint not null,
50  byte_null_hash tinyint,
51  byte_null_btree tinyint,
52  byte_null_both tinyint,
53  byte_null_none tinyint,
54 
55  short_not_null_hash smallint not null,
56  short_not_null_btree smallint not null,
57  short_not_null_both smallint not null,
58  short_not_null_none smallint not null,
59  short_null_hash smallint,
60  short_null_btree smallint,
61  short_null_both smallint,
62  short_null_none smallint,
63 
64  long_not_null_hash bigint not null,
65  long_not_null_btree bigint not null,
66  long_not_null_both bigint not null,
67  long_not_null_none bigint not null,
68  long_null_hash bigint,
69  long_null_btree bigint,
70  long_null_both bigint,
71  long_null_none bigint
72  */
73 
74  @Override
75  public Class<?> getInstanceType() {
76  return AllPrimitives.class;
77  }
78 
79  @Override
80  void createInstances(int number) {
81  createAllPrimitivesInstances(10);
82  }
83 
84  public void testExtraEqualNull() {
85  equalAnd1ExtraQuery("int_not_null_btree", 8, "int_null_none", extraEqualPredicateProvider, null, "idx_int_not_null_btree");
86  equalAnd1ExtraQuery("int_not_null_hash", 8, "int_null_none", extraEqualPredicateProvider, null, "none");
87  equalAnd1ExtraQuery("int_not_null_both", 8, "int_null_none", extraEqualPredicateProvider, null, "idx_int_not_null_both");
88  equalAnd1ExtraQuery("int_not_null_none", 8, "int_null_none", extraEqualPredicateProvider, null, "none");
89  failOnError();
90  }
91 
92  public void testBtreeEqualNull() {
93  equalQuery("int_not_null_btree", "none", null);
94  equalQuery("int_null_btree", "none", null);
95  failOnError();
96  }
97 
98  public void testHashEqualNull() {
99  equalQuery("int_not_null_hash", "none", null);
100  equalQuery("int_null_hash", "none", null);
101  failOnError();
102  }
103 
104  public void testBothEqualNull() {
105  equalQuery("int_not_null_both", "none", null);
106  equalQuery("int_null_both", "none", null);
107  failOnError();
108  }
109 
110  public void testNoneEqualNull() {
111  equalQuery("int_not_null_none", "none", null);
112  equalQuery("int_null_none", "none", null);
113  failOnError();
114  }
115 
116  public void testGreaterThanNull() {
117  try {
118  greaterThanQuery("int_not_null_btree", "none", null);
119  error("Greater than query should throw ClusterJUserException with null parameter.");
120  } catch (ClusterJUserException ex) {
121  // good catch
122  }
123  }
124 
125  public void testGreaterEqualNull() {
126  try {
127  greaterEqualQuery("int_not_null_btree", "none", null);
128  error("Greater equal query should throw ClusterJUserException with null parameter.");
129  } catch (ClusterJUserException ex) {
130  // good catch
131  }
132  }
133 
134  public void testLessThanNull() {
135  try {
136  lessThanQuery("int_not_null_btree", "none", null);
137  error("Less than query should throw ClusterJUserException with null parameter.");
138  } catch (ClusterJUserException ex) {
139  // good catch
140  }
141  }
142 
143  public void testLessEqualNull() {
144  try {
145  lessEqualQuery("int_not_null_btree", "none", null);
146  error("Less equal query should throw ClusterJUserException with null parameter.");
147  } catch (ClusterJUserException ex) {
148  // good catch
149  }
150  }
151 
152 }