2 Copyright 2010 Sun Microsystems, Inc.
3 All rights reserved. Use is subject to license terms.
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.
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.
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
19 package com.mysql.clusterj.openjpatest;
21 import com.mysql.clusterj.jpatest.AbstractJPABaseTest;
22 import com.mysql.clusterj.jpatest.model.LongLongStringPK;
23 import com.mysql.clusterj.jpatest.model.LongLongStringOid;
28 public class LongLongStringPKTest extends AbstractJPABaseTest {
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;
42 em = emf.createEntityManager();
43 print("Removing " + NUMBER_OF_A + " instances of LongLongStringPK.");
45 for (int i = OFFSET_A; i < OFFSET_A + NUMBER_OF_A; ++i) {
46 LongLongStringOid oid = new LongLongStringOid(i);
47 a = em.find(LongLongStringPK.class, oid);
56 em = emf.createEntityManager();
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);
66 em = emf.createEntityManager();
67 print("Finding " + NUMBER_OF_A + " instances of LongLongStringPK.");
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);
79 private void print(String string) {
81 System.out.println(string);
85 /** Verify that the primary keys match the oid.
87 * @param oid the oid used to find the instance
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());