2 Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; version 2 of the License.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 package testsuite.clusterj;
20 import com.mysql.clusterj.ClusterJException;
22 import testsuite.clusterj.model.Employee;
24 public class VarcharStringLengthTest extends AbstractClusterJTest {
26 private static String name =
27 "11111111111111111111111111111111111111111111111111" +
28 "11111111111111111111111111111111111111111111111111" +
29 "11111111111111111111111111111111111111111111111111" +
30 "11111111111111111111111111111111111111111111111111" +
31 "11111111111111111111111111111111111111111111111111" +
32 "11111111111111111111111111111111111111111111111111" +
33 "11111111111111111111111111111111111111111111111111" +
34 "11111111111111111111111111111111111111111111111111" +
35 "11111111111111111111111111111111111111111111111111" +
36 "11111111111111111111111111111111111111111111111111";
39 public void localSetUp() {
40 createSessionFactory();
41 session = sessionFactory.getSession();
42 session.deletePersistentAll(Employee.class);
43 addTearDownClasses(Employee.class);
47 for (int i = 0; i < 500; ++i) {
48 Employee e = session.newInstance(Employee.class, i);
49 e.setName(name.substring(0, i));
53 session.makePersistent(e);
55 // unexpected success for lengths greater than varchar size
56 error("Expected exception not thrown for: " + i);
58 } catch (ClusterJException ex) {
60 // unexpected error for lengths not greater than varchar size
61 error("Unexpected exception for: " + i + " " + ex.getMessage());