01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package org.apache.openjpa.slice;
20:
21: import javax.persistence.*;
22:
23: public class TestXA extends SliceTestCase {
24: public void setUp() throws Exception {
25: super .setUp(PObject.class, Person.class, Address.class,
26: CLEAR_TABLES);
27: }
28:
29: public void testEmptyCommit() {
30: EntityManager em = emf.createEntityManager();
31: em.getTransaction().begin();
32: em.getTransaction().commit();
33: }
34:
35: public void testEmptyRollback() {
36: EntityManager em = emf.createEntityManager();
37: em.getTransaction().begin();
38: em.getTransaction().rollback();
39: }
40:
41: public void testPersistIndependentObjects() {
42: EntityManager em = emf.createEntityManager();
43: int before = count(PObject.class);
44: int N = 2;
45: em.getTransaction().begin();
46: for (int i = 0; i < N; i++)
47: em.persist(new PObject());
48: em.getTransaction().commit();
49: em.clear();
50: int after = count(PObject.class);
51: assertEquals(before + N, after);
52: }
53:
54: protected String getPersistenceUnitName() {
55: return "XA";
56: }
57:
58: }
|