MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DateAsSqlDateTypesTest.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 java.sql.Date;
22 import java.sql.PreparedStatement;
23 import java.sql.ResultSet;
24 import java.sql.SQLException;
25 import testsuite.clusterj.model.DateAsSqlDateTypes;
26 import testsuite.clusterj.model.IdBase;
27 
59 
60  static int NUMBER_OF_INSTANCES = 10;
61 
62  @Override
63  protected boolean getDebug() {
64  return false;
65  }
66 
67  @Override
68  protected int getNumberOfInstances() {
69  return NUMBER_OF_INSTANCES;
70  }
71 
72  @Override
73  protected String getTableName() {
74  return "datetypes";
75  }
76 
78  @Override
79  Class<? extends IdBase> getModelClass() {
80  return DateAsSqlDateTypes.class;
81  }
82 
84  @Override
85  protected Object getColumnValue(int i, int j) {
86  return new Date(getMillisFor(1980, i, j + 1));
87  }
88 
89  public void testWriteJDBCReadNDB() {
91  failOnError();
92  }
93 
94  public void testWriteNDBReadNDB() {
96  failOnError();
97  }
98 
99  public void testWriteJDBCReadJDBC() {
101  failOnError();
102  }
103 
104  public void testWriteNDBReadJDBC() {
106  failOnError();
107  }
108 
109  static ColumnDescriptor not_null_hash = new ColumnDescriptor
110  ("date_not_null_hash", new InstanceHandler() {
111  public void setFieldValue(IdBase instance, Object value) {
112  ((DateAsSqlDateTypes)instance).setDate_not_null_hash((Date)value);
113  }
114  public Object getFieldValue(IdBase instance) {
115  return ((DateAsSqlDateTypes)instance).getDate_not_null_hash();
116  }
117  public void setPreparedStatementValue(PreparedStatement preparedStatement, int j, Object value)
118  throws SQLException {
119  preparedStatement.setDate(j, (Date)value);
120  }
121  public Object getResultSetValue(ResultSet rs, int j) throws SQLException {
122  return rs.getDate(j);
123  }
124  });
125 
126  static ColumnDescriptor not_null_btree = new ColumnDescriptor
127  ("date_not_null_btree", new InstanceHandler() {
128  public void setFieldValue(IdBase instance, Object value) {
129  ((DateAsSqlDateTypes)instance).setDate_not_null_btree((Date)value);
130  }
131  public Object getFieldValue(IdBase instance) {
132  return ((DateAsSqlDateTypes)instance).getDate_not_null_btree();
133  }
134  public void setPreparedStatementValue(PreparedStatement preparedStatement, int j, Object value)
135  throws SQLException {
136  preparedStatement.setDate(j, (Date)value);
137  }
138  public Object getResultSetValue(ResultSet rs, int j) throws SQLException {
139  return rs.getDate(j);
140  }
141  });
142  static ColumnDescriptor not_null_both = new ColumnDescriptor
143  ("date_not_null_both", new InstanceHandler() {
144  public void setFieldValue(IdBase instance, Object value) {
145  ((DateAsSqlDateTypes)instance).setDate_not_null_both((Date)value);
146  }
147  public Date getFieldValue(IdBase instance) {
148  return ((DateAsSqlDateTypes)instance).getDate_not_null_both();
149  }
150  public void setPreparedStatementValue(PreparedStatement preparedStatement, int j, Object value)
151  throws SQLException {
152  preparedStatement.setDate(j, (Date)value);
153  }
154  public Object getResultSetValue(ResultSet rs, int j) throws SQLException {
155  return rs.getDate(j);
156  }
157  });
158  static ColumnDescriptor not_null_none = new ColumnDescriptor
159  ("date_not_null_none", new InstanceHandler() {
160  public void setFieldValue(IdBase instance, Object value) {
161  ((DateAsSqlDateTypes)instance).setDate_not_null_none((Date)value);
162  }
163  public Date getFieldValue(IdBase instance) {
164  return ((DateAsSqlDateTypes)instance).getDate_not_null_none();
165  }
166  public void setPreparedStatementValue(PreparedStatement preparedStatement, int j, Object value)
167  throws SQLException {
168  preparedStatement.setDate(j, (Date)value);
169  }
170  public Object getResultSetValue(ResultSet rs, int j) throws SQLException {
171  return rs.getDate(j);
172  }
173  });
174 
175  protected static ColumnDescriptor[] columnDescriptors = new ColumnDescriptor[] {
176  not_null_hash,
177  not_null_btree,
178  not_null_both,
179  not_null_none
180  };
181 
182  @Override
183  protected ColumnDescriptor[] getColumnDescriptors() {
184  return columnDescriptors;
185  }
186 
187 }