MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DatetimeAsUtilDateTypesTest.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.PreparedStatement;
22 import java.sql.ResultSet;
23 import java.sql.SQLException;
24 import java.sql.Timestamp;
25 import java.util.Date;
26 
27 import testsuite.clusterj.model.DatetimeAsUtilDateTypes;
28 import testsuite.clusterj.model.IdBase;
29 
60 
61  static int NUMBER_OF_INSTANCES = 10;
62 
63  @Override
64  protected boolean getDebug() {
65  return false;
66  }
67 
68  @Override
69  protected int getNumberOfInstances() {
70  return NUMBER_OF_INSTANCES;
71  }
72 
73  @Override
74  protected String getTableName() {
75  return "datetimetypes";
76  }
77 
79  @Override
80  Class<? extends IdBase> getModelClass() {
81  return DatetimeAsUtilDateTypes.class;
82  }
83 
85  @Override
86  protected Object getColumnValue(int i, int j) {
87  return new Date(getMillisFor(1980, 0, i + 1, 0, 0, j));
88  }
89 
90  public void testWriteJDBCReadNDB() {
92  failOnError();
93  }
94 
95  public void testWriteNDBReadNDB() {
97  failOnError();
98  }
99 
100  public void testWriteJDBCReadJDBC() {
102  failOnError();
103  }
104 
105  public void testWriteNDBReadJDBC() {
107  failOnError();
108  }
109 
110  static ColumnDescriptor not_null_hash = new ColumnDescriptor
111  ("datetime_not_null_hash", new InstanceHandler() {
112  public void setFieldValue(IdBase instance, Object value) {
113  ((DatetimeAsUtilDateTypes)instance).setDatetime_not_null_hash((Date)value);
114  }
115  public Object getFieldValue(IdBase instance) {
116  return ((DatetimeAsUtilDateTypes)instance).getDatetime_not_null_hash();
117  }
118  public void setPreparedStatementValue(PreparedStatement preparedStatement, int j, Object value)
119  throws SQLException {
120  preparedStatement.setTimestamp(j, new Timestamp(((Date)value).getTime()));
121  }
122  public Object getResultSetValue(ResultSet rs, int j) throws SQLException {
123  return rs.getTimestamp(j);
124  }
125  });
126 
127  static ColumnDescriptor not_null_btree = new ColumnDescriptor
128  ("datetime_not_null_btree", new InstanceHandler() {
129  public void setFieldValue(IdBase instance, Object value) {
130  ((DatetimeAsUtilDateTypes)instance).setDatetime_not_null_btree((Date)value);
131  }
132  public Object getFieldValue(IdBase instance) {
133  return ((DatetimeAsUtilDateTypes)instance).getDatetime_not_null_btree();
134  }
135  public void setPreparedStatementValue(PreparedStatement preparedStatement, int j, Object value)
136  throws SQLException {
137  preparedStatement.setTimestamp(j, new Timestamp(((Date)value).getTime()));
138  }
139  public Object getResultSetValue(ResultSet rs, int j) throws SQLException {
140  return rs.getTimestamp(j);
141  }
142  });
143 
144  static ColumnDescriptor not_null_both = new ColumnDescriptor
145  ("datetime_not_null_both", new InstanceHandler() {
146  public void setFieldValue(IdBase instance, Object value) {
147  ((DatetimeAsUtilDateTypes)instance).setDatetime_not_null_both((Date)value);
148  }
149  public Date getFieldValue(IdBase instance) {
150  return ((DatetimeAsUtilDateTypes)instance).getDatetime_not_null_both();
151  }
152  public void setPreparedStatementValue(PreparedStatement preparedStatement, int j, Object value)
153  throws SQLException {
154  preparedStatement.setTimestamp(j, new Timestamp(((Date)value).getTime()));
155  }
156  public Object getResultSetValue(ResultSet rs, int j) throws SQLException {
157  return rs.getTimestamp(j);
158  }
159  });
160 
161  static ColumnDescriptor not_null_none = new ColumnDescriptor
162  ("datetime_not_null_none", new InstanceHandler() {
163  public void setFieldValue(IdBase instance, Object value) {
164  ((DatetimeAsUtilDateTypes)instance).setDatetime_not_null_none((Date)value);
165  }
166  public Date getFieldValue(IdBase instance) {
167  return ((DatetimeAsUtilDateTypes)instance).getDatetime_not_null_none();
168  }
169  public void setPreparedStatementValue(PreparedStatement preparedStatement, int j, Object value)
170  throws SQLException {
171  preparedStatement.setTimestamp(j, new Timestamp(((Date)value).getTime()));
172  }
173  public Object getResultSetValue(ResultSet rs, int j) throws SQLException {
174  return rs.getTimestamp(j);
175  }
176  });
177 
178  protected static ColumnDescriptor[] columnDescriptors = new ColumnDescriptor[] {
179  not_null_hash,
180  not_null_btree,
181  not_null_both,
182  not_null_none
183  };
184 
185  @Override
186  protected ColumnDescriptor[] getColumnDescriptors() {
187  return columnDescriptors;
188  }
189 
190 }