MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LongLongStringPKTest.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 com.mysql.clusterj.openjpatest;
20 
21 import com.mysql.clusterj.jpatest.AbstractJPABaseTest;
22 import com.mysql.clusterj.jpatest.model.LongLongStringPK;
23 import com.mysql.clusterj.jpatest.model.LongLongStringOid;
24 
29 
30  private int NUMBER_OF_A = 2;
31  private int OFFSET_A = 100;
32  // set this to true for debug output
33  private boolean print = false;
34 
35  @Override
36  public void setUp() {
37  super.setUp();
38  }
39 
40  public void test() {
42  em = emf.createEntityManager();
43  print("Removing " + NUMBER_OF_A + " instances of LongLongStringPK.");
44  begin();
45  for (int i = OFFSET_A; i < OFFSET_A + NUMBER_OF_A; ++i) {
47  a = em.find(LongLongStringPK.class, oid);
48  if (a != null) {
49  verify(oid, a);
50  em.remove(a);
51  }
52  }
53  commit();
54  em.close();
55 
56  em = emf.createEntityManager();
57  begin();
58  print("Creating " + NUMBER_OF_A + " instances of LongLongStringPK.");
59  for (int i = OFFSET_A; i < OFFSET_A + NUMBER_OF_A; ++i) {
60  a = LongLongStringPK.create(i);
61  em.persist(a);
62  }
63  commit();
64  em.close();
65 
66  em = emf.createEntityManager();
67  print("Finding " + NUMBER_OF_A + " instances of LongLongStringPK.");
68  begin();
69  for (int i = OFFSET_A; i < OFFSET_A + NUMBER_OF_A; ++i) {
70  LongLongStringOid oid = new LongLongStringOid(i);
71  a = em.find(LongLongStringPK.class, oid);
72  }
73  commit();
74  em.close();
75 
76  failOnError();
77  }
78 
79  private void print(String string) {
80  if (print) {
81  System.out.println(string);
82  }
83  }
84 
89  public void verify(LongLongStringOid oid, LongLongStringPK instance) {
90  errorIfNotEqual("Mismatch longpk1", oid.longpk1, instance.getLongpk1());
91  errorIfNotEqual("Mismatch longpk2", oid.longpk2, instance.getLongpk2());
92  errorIfNotEqual("Mismatch stringpk", oid.stringpk, instance.getStringpk());
93  }
94 
95 }