]> review.fuel-infra Code Review - packages/trusty/mysql-wsrep-5.6.git/blob
7973c67d7f861f8fa4a7b7b94b48e116e6f9a379
[packages/trusty/mysql-wsrep-5.6.git] /
1 /*
2    Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3
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.
7
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.
12
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
16 */
17
18 package com.mysql.clusterj.jpatest;
19
20 import com.mysql.clusterj.jpatest.model.Embedded;
21 import com.mysql.clusterj.jpatest.model.Embedding;
22 import com.mysql.clusterj.jpatest.model.IdBase;
23
24
25 /** Test Embedded class support. Currently only remove and insert are tested.
26  * 
27  * Schema
28  * 
29 drop table if exists t_basic;
30 create table t_basic (
31   id int not null,
32   name varchar(32), // embedded
33   age int,          // embedded
34   magic int not null,
35   primary key(id)) 
36   engine=ndbcluster;
37 create unique index idx_unique_hash_magic using hash on t_basic(magic);
38 create index idx_btree_age on t_basic(age);
39
40 */
41 @Ignore
42 public class EmbeddedTest extends AbstractJPABaseTest {
43
44     private int NUMBER_OF_INSTANCES = 10;
45
46     @Override
47     protected boolean getDebug() {
48         return false;
49     }
50
51     /** Subclasses must override this method to provide the model class for the test */
52     protected Class<? extends IdBase> getModelClass() {
53         return Embedding.class;
54     }
55
56     /**
57      * The name of the persistence unit that this test class should use
58      * by default. This defaults to "ndb".
59      */
60     @Override
61     protected String getPersistenceUnitName() {
62         return "ndb";
63     }
64
65     public void test() {
66         removeAll(Embedding.class);
67         em.getTransaction().begin();
68         for (int i = 0; i < NUMBER_OF_INSTANCES ; ++i) {
69             Embedding e = createEmbedding(i);
70             em.persist(e);
71         }
72         em.getTransaction().commit();
73     }
74
75     private Embedding createEmbedding(int i) {
76         Embedded embedded = new Embedded();
77         embedded.setAge(i);
78         embedded.setName("Embedded " + i);
79         Embedding embedding = new Embedding();
80         embedding.setId(i);
81         embedding.setMagic(i);
82         embedding.setEmbedded(embedded);
83         return embedding;
84     }
85
86 }