MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DecimalTypesTest.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.math.BigDecimal;
22 import java.sql.PreparedStatement;
23 import java.sql.ResultSet;
24 import java.sql.SQLException;
25 
26 import testsuite.clusterj.model.DecimalTypes;
27 import testsuite.clusterj.model.IdBase;
28 
30 
50  public void testWriteJDBCReadNDB() {
52  failOnError();
53  }
54 
56  public void testWriteNDBReadJDBC() {
58  failOnError();
59  }
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 "decimaltypes";
76  }
77 
79  @Override
80  Class<? extends IdBase> getModelClass() {
81  return DecimalTypes.class;
82  }
83 
85  @Override
86  protected Object getColumnValue(int i, int j) {
87  return BigDecimal.valueOf(i).add(BigDecimal.valueOf(j, 5));
88  }
89 
90  static ColumnDescriptor decimal_null_hash = new ColumnDescriptor
91  ("decimal_null_hash", new InstanceHandler() {
92  public void setFieldValue(IdBase instance, Object value) {
93  ((DecimalTypes)instance).setDecimal_null_hash((BigDecimal)value);
94  }
95  public Object getFieldValue(IdBase instance) {
96  return ((DecimalTypes)instance).getDecimal_null_hash();
97  }
98  public void setPreparedStatementValue(PreparedStatement preparedStatement, int j, Object value)
99  throws SQLException {
100  preparedStatement.setBigDecimal(j, (BigDecimal)value);
101  }
102  public Object getResultSetValue(ResultSet rs, int j) throws SQLException {
103  return rs.getBigDecimal(j);
104  }
105  });
106 
107  static ColumnDescriptor decimal_null_btree = new ColumnDescriptor
108  ("decimal_null_btree", new InstanceHandler() {
109  public void setFieldValue(IdBase instance, Object value) {
110  ((DecimalTypes)instance).setDecimal_null_btree((BigDecimal)value);
111  }
112  public Object getFieldValue(IdBase instance) {
113  return ((DecimalTypes)instance).getDecimal_null_btree();
114  }
115  public void setPreparedStatementValue(PreparedStatement preparedStatement, int j, Object value)
116  throws SQLException {
117  preparedStatement.setBigDecimal(j, (BigDecimal)value);
118  }
119  public Object getResultSetValue(ResultSet rs, int j) throws SQLException {
120  return rs.getBigDecimal(j);
121  }
122  });
123  static ColumnDescriptor decimal_null_both = new ColumnDescriptor
124  ("decimal_null_both", new InstanceHandler() {
125  public void setFieldValue(IdBase instance, Object value) {
126  ((DecimalTypes)instance).setDecimal_null_both((BigDecimal)value);
127  }
128  public BigDecimal getFieldValue(IdBase instance) {
129  return ((DecimalTypes)instance).getDecimal_null_both();
130  }
131  public void setPreparedStatementValue(PreparedStatement preparedStatement, int j, Object value)
132  throws SQLException {
133  preparedStatement.setBigDecimal(j, (BigDecimal)value);
134  }
135  public Object getResultSetValue(ResultSet rs, int j) throws SQLException {
136  return rs.getBigDecimal(j);
137  }
138  });
139  static ColumnDescriptor decimal_null_none = new ColumnDescriptor
140  ("decimal_null_none", new InstanceHandler() {
141  public void setFieldValue(IdBase instance, Object value) {
142  ((DecimalTypes)instance).setDecimal_null_none((BigDecimal)value);
143  }
144  public BigDecimal getFieldValue(IdBase instance) {
145  return ((DecimalTypes)instance).getDecimal_null_none();
146  }
147  public void setPreparedStatementValue(PreparedStatement preparedStatement, int j, Object value)
148  throws SQLException {
149  preparedStatement.setBigDecimal(j, (BigDecimal)value);
150  }
151  public Object getResultSetValue(ResultSet rs, int j) throws SQLException {
152  return rs.getBigDecimal(j);
153  }
154  });
155 
156  protected static ColumnDescriptor[] columnDescriptors = new ColumnDescriptor[] {
157  decimal_null_hash,
158  decimal_null_btree,
159  decimal_null_both,
160  decimal_null_none
161  };
162 
163  @Override
164  protected ColumnDescriptor[] getColumnDescriptors() {
165  return columnDescriptors;
166  }
167 
168 }