Source Code Cross Referenced for A_omu.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » jtests » clients » entity » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » JOnAS 4.8.6 » org.objectweb.jonas.jtests.clients.entity 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * JOnAS: Java(TM) Open Application Server
0003:         * Copyright (C) 1999 Bull S.A.
0004:         * Contact: jonas-team@objectweb.org
0005:         *
0006:         * This library is free software; you can redistribute it and/or
0007:         * modify it under the terms of the GNU Lesser General Public
0008:         * License as published by the Free Software Foundation; either
0009:         * version 2.1 of the License, or any later version.
0010:         *
0011:         * This library is distributed in the hope that it will be useful,
0012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014:         * Lesser General Public License for more details.
0015:         *
0016:         * You should have received a copy of the GNU Lesser General Public
0017:         * License along with this library; if not, write to the Free Software
0018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
0019:         * USA
0020:         *
0021:         * --------------------------------------------------------------------------
0022:         * $Id: A_omu.java 10108 2007-03-28 09:21:26Z durieuxp $
0023:         * --------------------------------------------------------------------------
0024:         */
0025:
0026:        package org.objectweb.jonas.jtests.clients.entity;
0027:
0028:        import junit.framework.Test;
0029:        import junit.framework.TestSuite;
0030:        import javax.naming.NamingException;
0031:        import javax.rmi.PortableRemoteObject;
0032:        import java.util.ArrayList;
0033:        import java.util.Collection;
0034:        import java.util.Enumeration;
0035:        import java.util.Hashtable;
0036:        import java.util.Iterator;
0037:
0038:        import org.objectweb.jonas.jtests.beans.relation.omu.AHomeRemote;
0039:        import org.objectweb.jonas.jtests.beans.relation.omu.ARemote;
0040:        import org.objectweb.jonas.jtests.beans.relation.omu.BHomeRemote;
0041:        import org.objectweb.jonas.jtests.beans.relation.omu.BRemote;
0042:
0043:        /**
0044:         * For testing one-to-many unidirectional relationships
0045:         * @author S.Chassande-Barrioz, Helene Joanin
0046:         */
0047:
0048:        public abstract class A_omu extends A_Cmp2Util {
0049:
0050:            public abstract AHomeRemote getAHome();
0051:
0052:            public abstract BHomeRemote getBHome();
0053:
0054:            static Hashtable tbRelationA2B = new Hashtable();
0055:
0056:            static {
0057:                tbRelationA2B.put("as0", new String[] {});
0058:                tbRelationA2B.put("as1", new String[] { "bs1_1" });
0059:                tbRelationA2B.put("as2", new String[] { "bs2_1", "bs2_2",
0060:                        "bs2_3" });
0061:                tbRelationA2B.put("a0", new String[] {});
0062:                tbRelationA2B
0063:                        .put("a1", new String[] { "b1_1", "b1_2", "b1_3" });
0064:                tbRelationA2B
0065:                        .put("a2", new String[] { "b2_1", "b2_2", "b2_3" });
0066:                tbRelationA2B.put("a3", new String[] { "b3_1" });
0067:                // Translate the String[] to a Collection of String
0068:                for (Enumeration ea = tbRelationA2B.keys(); ea
0069:                        .hasMoreElements();) {
0070:                    String aname = (String) (ea.nextElement());
0071:                    String[] tb = (String[]) tbRelationA2B.get(aname);
0072:                    ArrayList col = new ArrayList(tb.length);
0073:                    for (int i = 0; i < tb.length; i++) {
0074:                        col.add(tb[i]);
0075:                    }
0076:                    tbRelationA2B.put(aname, col);
0077:                }
0078:            }
0079:
0080:            public A_omu(String name) {
0081:                super (name);
0082:            }
0083:
0084:            protected boolean isInit = false;
0085:
0086:            protected void setUp() {
0087:                super .setUp();
0088:                boolean ok = false;
0089:                int nbtry = 0;
0090:                while (!ok && nbtry < 3) {
0091:                    if (!isInit) {
0092:                        // load bean if not loaded yet
0093:                        useBeans("omu", true);
0094:                        // check if tables have been initialized
0095:                        try {
0096:                            getAHome().findByPrimaryKey("a0");
0097:                        } catch (Exception e) {
0098:                            try {
0099:                                utx.begin();
0100:                                getBHome().create("bs0");
0101:                                getBHome().create("bs1_1");
0102:                                getBHome().create("bs2_1");
0103:                                getBHome().create("bs2_2");
0104:                                getBHome().create("bs2_3");
0105:                                getBHome().create("bs3");
0106:                                getBHome().create("b0");
0107:                                getBHome().create("b1_1");
0108:                                getBHome().create("b1_2");
0109:                                getBHome().create("b1_3");
0110:                                getBHome().create("b2_1");
0111:                                getBHome().create("b2_2");
0112:                                getBHome().create("b2_3");
0113:                                getBHome().create("b3_1");
0114:                                ARemote as0 = getAHome().create("as0");
0115:                                ARemote as1 = getAHome().create("as1");
0116:                                ARemote as2 = getAHome().create("as2");
0117:                                ARemote a0 = getAHome().create("a0");
0118:                                ARemote a1 = getAHome().create("a1");
0119:                                ARemote a2 = getAHome().create("a2");
0120:                                ARemote a3 = getAHome().create("a3");
0121:                                as1.assignB((Collection) tbRelationA2B
0122:                                        .get("as1"));
0123:                                as2.assignB((Collection) tbRelationA2B
0124:                                        .get("as2"));
0125:                                a1
0126:                                        .assignB((Collection) tbRelationA2B
0127:                                                .get("a1"));
0128:                                a2
0129:                                        .assignB((Collection) tbRelationA2B
0130:                                                .get("a2"));
0131:                                a3
0132:                                        .assignB((Collection) tbRelationA2B
0133:                                                .get("a3"));
0134:                            } catch (Exception i) {
0135:                                fail("InitialState creation problem:: " + i);
0136:                            } finally {
0137:                                try {
0138:                                    utx.commit();
0139:                                } catch (Exception ii) {
0140:                                }
0141:                            }
0142:                        }
0143:                        isInit = true;
0144:                    }
0145:                    // Check that all is OK. Sometimes, a test has failed and has corrupted
0146:                    // the bean state in the database. We must unload and reload the bean then.
0147:                    nbtry++;
0148:                    try {
0149:                        if (initStateOK()) {
0150:                            ok = true;
0151:                        }
0152:                    } catch (Exception e) {
0153:                    }
0154:                    if (!ok) {
0155:                        isInit = false;
0156:                        unloadBeans("omu");
0157:                    }
0158:                }
0159:            }
0160:
0161:            /*
0162:             * Check that we are in the same state as after the tables creation for thoses beans A and B
0163:             * (ie if it is the initial state)
0164:             */
0165:            boolean initStateOK() throws Exception {
0166:                boolean isOk = true;
0167:                msgerror = new StringBuffer();
0168:                for (Enumeration ea = tbRelationA2B.keys(); ea
0169:                        .hasMoreElements();) {
0170:                    String aname = (String) (ea.nextElement());
0171:                    ARemote a = getAHome().findByPrimaryKey(aname);
0172:                    Collection colActual = a.retrieveB();
0173:                    ArrayList colExpected = (ArrayList) (tbRelationA2B
0174:                            .get(aname));
0175:                    debug("Relation for " + aname + " :: expected:"
0176:                            + colExpected + ", found:" + colActual);
0177:                    if (!isCollectionEqual(colExpected, colActual)) {
0178:                        isOk = false;
0179:                        msgerror = msgerror.append("Wrong relation for "
0180:                                + aname + " (expected:" + colExpected
0181:                                + ", found:" + colActual + ")");
0182:                    }
0183:                }
0184:                return isOk;
0185:            }
0186:
0187:            /**
0188:             * read A, but not B
0189:             */
0190:            public void testReadA() throws Exception {
0191:                Collection c = getAHome().findAll();
0192:                for (Iterator i = c.iterator(); i.hasNext();) {
0193:                    ARemote a = (ARemote) PortableRemoteObject.narrow(i.next(),
0194:                            ARemote.class);
0195:                    String n = a.getId();
0196:                }
0197:            }
0198:
0199:            /**
0200:             * Check that the bean 'as0' has no relation.
0201:             */
0202:            public void _testBasicGetEmpty(int tx) throws Exception {
0203:                Collection c = null;
0204:                if ((tx == TX_CALL) || (tx == TX_RB)) {
0205:                    utx.begin();
0206:                }
0207:                ARemote a = getAHome().findByPrimaryKey("as0");
0208:                if (tx == TX_CONT) {
0209:                    c = a.retrieveBInNewTx();
0210:                } else {
0211:                    c = a.retrieveB();
0212:                }
0213:                if (tx == TX_CALL) {
0214:                    utx.commit();
0215:                } else if (tx == TX_RB) {
0216:                    utx.rollback();
0217:                }
0218:                checkIsInitialState();
0219:            }
0220:
0221:            public void testBasicGetEmptyTxNo() throws Exception {
0222:                _testBasicGetEmpty(TX_NO);
0223:            }
0224:
0225:            public void testBasicGetEmptyTxCall() throws Exception {
0226:                _testBasicGetEmpty(TX_CALL);
0227:            }
0228:
0229:            public void testBasicGetEmptyTxCont() throws Exception {
0230:                _testBasicGetEmpty(TX_CONT);
0231:            }
0232:
0233:            /**
0234:             * Check that the bean 'as1' has only one relation with 'bs1_1'.
0235:             */
0236:            public void _testBasicGetOne(int tx) throws Exception {
0237:
0238:                Collection c = null;
0239:                if ((tx == TX_CALL) || (tx == TX_RB)) {
0240:                    utx.begin();
0241:                }
0242:                ARemote a = getAHome().findByPrimaryKey("as1");
0243:                if (tx == TX_CONT) {
0244:                    c = a.retrieveBInNewTx();
0245:                } else {
0246:                    c = a.retrieveB();
0247:                }
0248:                if (tx == TX_CALL) {
0249:                    utx.commit();
0250:                } else if (tx == TX_RB) {
0251:                    utx.rollback();
0252:                }
0253:                // checking
0254:                assertEquals("Wrong relations size for as1: ", 1, c.size());
0255:                String s = "bs1_1";
0256:                assertTrue("Relation missing " + s + " for as1: ", c
0257:                        .contains(s));
0258:                checkIsInitialState();
0259:            }
0260:
0261:            public void testBasicGetOneTxNo() throws Exception {
0262:                _testBasicGetOne(TX_NO);
0263:            }
0264:
0265:            public void testBasicGetOneTxCall() throws Exception {
0266:                _testBasicGetOne(TX_CALL);
0267:            }
0268:
0269:            public void testBasicGetOneTxCont() throws Exception {
0270:                _testBasicGetOne(TX_CONT);
0271:            }
0272:
0273:            public void testBasicGetOneTxRb() throws Exception {
0274:                _testBasicGetOne(TX_RB);
0275:            }
0276:
0277:            /**
0278:             * Check that the bean 'as2' has many relations with 'bs2_1', 'bs2_2', 'bs2_3'.
0279:             */
0280:            public void _testBasicGetMany(int tx) throws Exception {
0281:
0282:                Collection c = null;
0283:                if ((tx == TX_CALL) || (tx == TX_RB)) {
0284:                    utx.begin();
0285:                }
0286:                ARemote a = getAHome().findByPrimaryKey("as2");
0287:                if (tx == TX_CONT) {
0288:                    c = a.retrieveBInNewTx();
0289:                } else {
0290:                    c = a.retrieveB();
0291:                }
0292:                if (tx == TX_CALL) {
0293:                    utx.commit();
0294:                } else if (tx == TX_RB) {
0295:                    utx.rollback();
0296:                }
0297:                // checking
0298:                assertEquals("Relations size of: ", 3, c.size());
0299:                String s = "bs2_1";
0300:                assertTrue("Relation missing " + s + ": ", c.contains(s));
0301:                s = "bs2_2";
0302:                assertTrue("Relation missing " + s + ": ", c.contains(s));
0303:                s = "bs2_3";
0304:                assertTrue("Relation missing " + s + ": ", c.contains(s));
0305:                checkIsInitialState();
0306:            }
0307:
0308:            public void testBasicGetManyTxNo() throws Exception {
0309:                _testBasicGetMany(TX_NO);
0310:            }
0311:
0312:            public void testBasicGetManyTxCall() throws Exception {
0313:                _testBasicGetMany(TX_CALL);
0314:            }
0315:
0316:            public void testBasicGetManyTxCont() throws Exception {
0317:                _testBasicGetMany(TX_CONT);
0318:            }
0319:
0320:            /**
0321:             * Set a relation to empty.
0322:             * Before: as1 -> bs1_1
0323:             * After:  as1    bs1_1
0324:             */
0325:            public void _testBasicSetEmpty(int tx) throws Exception {
0326:                ArrayList ce = new ArrayList();
0327:                if ((tx == TX_CALL) || (tx == TX_RB)) {
0328:                    utx.begin();
0329:                }
0330:                ARemote a = getAHome().findByPrimaryKey("as1");
0331:                if (tx == TX_CONT) {
0332:                    a.assignBInNewTx(ce);
0333:                } else {
0334:                    a.assignB(ce);
0335:                }
0336:                if (tx == TX_CALL) {
0337:                    utx.commit();
0338:                } else if (tx == TX_RB) {
0339:                    utx.rollback();
0340:                }
0341:                // checking
0342:                Collection ca = a.retrieveB();
0343:                if (tx != TX_RB) {
0344:                    assertEquals("Relations size of: ", 0, ca.size());
0345:                } else {
0346:                    assertEquals("Relations size of: ", 1, ca.size());
0347:                }
0348:                // undo
0349:                if (tx != TX_RB) {
0350:                    a.addInB("bs1_1");
0351:                    // Check undo
0352:                    ca = a.retrieveB();
0353:                    assertEquals("After undo, Relations size of: ", 1, ca
0354:                            .size());
0355:                }
0356:                checkIsInitialState();
0357:            }
0358:
0359:            public void testBasicSetEmptyTxNo() throws Exception {
0360:                _testBasicSetEmpty(TX_NO);
0361:            }
0362:
0363:            public void testBasicSetEmptyTxCall() throws Exception {
0364:                _testBasicSetEmpty(TX_CALL);
0365:            }
0366:
0367:            public void testBasicSetEmptyTxCont() throws Exception {
0368:                _testBasicSetEmpty(TX_CONT);
0369:            }
0370:
0371:            public void testBasicSetEmptyTxRb() throws Exception {
0372:                _testBasicSetEmpty(TX_RB);
0373:            }
0374:
0375:            /**
0376:             * Set a relation to empty by clearing the collection.
0377:             * Before: as1 -> bs1_1
0378:             * After:  as1    bs1_1
0379:             */
0380:            public void _testBasicClear(int tx) throws Exception {
0381:                ArrayList ce = new ArrayList();
0382:                if ((tx == TX_CALL) || (tx == TX_RB)) {
0383:                    utx.begin();
0384:                }
0385:                ARemote a = getAHome().findByPrimaryKey("as1");
0386:                if (tx == TX_CONT) {
0387:                    a.clearBInNewTx();
0388:                } else {
0389:                    a.clearB();
0390:                }
0391:                if (tx == TX_CALL) {
0392:                    utx.commit();
0393:                } else if (tx == TX_RB) {
0394:                    utx.rollback();
0395:                }
0396:                // checking
0397:                Collection ca = a.retrieveB();
0398:                if (tx != TX_RB) {
0399:                    assertEquals("Relations size of: ", 0, ca.size());
0400:                } else {
0401:                    assertEquals("Relations size of: ", 1, ca.size());
0402:                }
0403:                // undo
0404:                if (tx != TX_RB) {
0405:                    a.addInB("bs1_1");
0406:                    // Check undo
0407:                    ca = a.retrieveB();
0408:                    assertEquals("After undo, Relations size of: ", 1, ca
0409:                            .size());
0410:                }
0411:                checkIsInitialState();
0412:            }
0413:
0414:            public void testBasicClearTxNo() throws Exception {
0415:                _testBasicClear(TX_NO);
0416:            }
0417:
0418:            public void testBasicClearTxCall() throws Exception {
0419:                _testBasicClear(TX_CALL);
0420:            }
0421:
0422:            public void testBasicClearTxCont() throws Exception {
0423:                _testBasicClear(TX_CONT);
0424:            }
0425:
0426:            public void testBasicClearTxRb() throws Exception {
0427:                _testBasicClear(TX_RB);
0428:            }
0429:
0430:            /**
0431:             * Set a empty relation with 1 element. This added element was'nt already in
0432:             * an other relation. Before: as0 b0 After: as0 -> b0
0433:             */
0434:            public void _testBasicSetOne(int tx) throws Exception {
0435:                ArrayList ce = new ArrayList();
0436:                ce.add("b0");
0437:                if ((tx == TX_CALL) || (tx == TX_RB)) {
0438:                    utx.begin();
0439:                }
0440:                ARemote a = getAHome().findByPrimaryKey("as0");
0441:                if (tx == TX_CONT) {
0442:                    a.assignBInNewTx(ce);
0443:                } else {
0444:                    a.assignB(ce);
0445:                }
0446:                if (tx == TX_CALL) {
0447:                    utx.commit();
0448:                } else if (tx == TX_RB) {
0449:                    utx.rollback();
0450:                }
0451:                // checking
0452:                Collection ca = a.retrieveB();
0453:                if (tx != TX_RB) {
0454:                    assertTrue("Wrong relations as0 (required:" + ce
0455:                            + ", found:" + ca + ")", isCollectionEqual(ce, ca));
0456:                } else {
0457:                    assertEquals("Relations size of: ", 0, ca.size());
0458:                }
0459:                // undo
0460:                if (tx != TX_RB) {
0461:                    a.assignB(new ArrayList());
0462:                    // Check undo
0463:                    ca = a.retrieveB();
0464:                    assertEquals("After undo, Relations size of: ", 0, ca
0465:                            .size());
0466:                }
0467:                checkIsInitialState();
0468:            }
0469:
0470:            public void testBasicSetOneTxNo() throws Exception {
0471:                _testBasicSetOne(TX_NO);
0472:            }
0473:
0474:            public void testBasicSetOneTxCall() throws Exception {
0475:                _testBasicSetOne(TX_CALL);
0476:            }
0477:
0478:            public void testBasicSetOneTxCont() throws Exception {
0479:                _testBasicSetOne(TX_CONT);
0480:            }
0481:
0482:            public void testBasicSetOneTxRb() throws Exception {
0483:                _testBasicSetOne(TX_RB);
0484:            }
0485:
0486:            /**
0487:             * Add an element to a empty relation.
0488:             * Same as _testBasicSetOne except that we add the element in the collection
0489:             * instead of we set directly the collection.
0490:             * Before: as0    bs0
0491:             * After:  as0 -> bs0
0492:             */
0493:            public void _testBasicAddOne(int tx) throws Exception {
0494:                ArrayList ce = new ArrayList();
0495:                ce.add("bs0");
0496:                if ((tx == TX_CALL) || (tx == TX_RB)) {
0497:                    utx.begin();
0498:                }
0499:                ARemote a = getAHome().findByPrimaryKey("as0");
0500:                if (tx == TX_CONT) {
0501:                    a.addInBInNewTx("bs0");
0502:                } else {
0503:                    a.addInB("bs0");
0504:                }
0505:                if (tx == TX_CALL) {
0506:                    utx.commit();
0507:                } else if (tx == TX_RB) {
0508:                    utx.rollback();
0509:                }
0510:                // checking
0511:                Collection ca = a.retrieveB();
0512:                if (tx != TX_RB) {
0513:                    assertTrue("Wrong relations as0 (required:" + ce
0514:                            + ", found:" + ca + ")", isCollectionEqual(ce, ca));
0515:                } else {
0516:                    assertEquals("Relations size of: ", 0, ca.size());
0517:                }
0518:                // undo
0519:                if (tx != TX_RB) {
0520:                    a.assignB(new ArrayList());
0521:                    // Check undo
0522:                    ca = a.retrieveB();
0523:                    assertEquals("After undo, Relations size of: ", 0, ca
0524:                            .size());
0525:                }
0526:                checkIsInitialState();
0527:            }
0528:
0529:            public void testBasicAddOneTxNo() throws Exception {
0530:                _testBasicAddOne(TX_NO);
0531:            }
0532:
0533:            public void testBasicAddOneTxCall() throws Exception {
0534:                _testBasicAddOne(TX_CALL);
0535:            }
0536:
0537:            public void testBasicAddOneTxCont() throws Exception {
0538:                _testBasicAddOne(TX_CONT);
0539:            }
0540:
0541:            public void testBasicAddOneTxRb() throws Exception {
0542:                _testBasicAddOne(TX_RB);
0543:            }
0544:
0545:            /**
0546:             * Re-Set a relation with N element.
0547:             * Before: as1 -> bs1_1
0548:             *                bs0
0549:             *                bs3
0550:             * After:  as1 -> bs0
0551:             *         as1 -> bs3
0552:             *                bs1_1
0553:             *
0554:             */
0555:            public void _testBasicSetMulti(int tx) throws Exception {
0556:                ArrayList ce = new ArrayList(2);
0557:                ce.add("bs0");
0558:                ce.add("bs3");
0559:                if ((tx == TX_CALL) || (tx == TX_RB)) {
0560:                    utx.begin();
0561:                }
0562:                ARemote a = getAHome().findByPrimaryKey("as1");
0563:                Collection co = a.retrieveB();
0564:                if (tx == TX_CONT) {
0565:                    a.assignBInNewTx(ce);
0566:                } else {
0567:                    a.assignB(ce);
0568:                }
0569:                if (tx == TX_CALL) {
0570:                    utx.commit();
0571:                } else if (tx == TX_RB) {
0572:                    utx.rollback();
0573:                }
0574:                // checking
0575:                Collection ca = a.retrieveB();
0576:                if (tx != TX_RB) {
0577:                    assertTrue("Wrong relations as1 (required:" + ce
0578:                            + ", found:" + ca + ")", isCollectionEqual(ce, ca));
0579:                } else {
0580:                    assertTrue("Wrong relations as1 (required:" + co
0581:                            + ", found:" + ca + ")", isCollectionEqual(co, ca));
0582:                }
0583:                // undo
0584:                if (tx != TX_RB) {
0585:                    a.assignB(co);
0586:                    // Check undo
0587:                    ca = a.retrieveB();
0588:                    assertTrue("After undo, wrong relations: ",
0589:                            isCollectionEqual(co, ca));
0590:                }
0591:                checkIsInitialState();
0592:            }
0593:
0594:            public void testBasicSetMultiTxNo() throws Exception {
0595:                _testBasicSetMulti(TX_NO);
0596:            }
0597:
0598:            public void testBasicSetMultiTxCall() throws Exception {
0599:                _testBasicSetMulti(TX_CALL);
0600:            }
0601:
0602:            public void testBasicSetMultiTxCont() throws Exception {
0603:                _testBasicSetMulti(TX_CONT);
0604:            }
0605:
0606:            public void testBasicSetMultiTxRb() throws Exception {
0607:                _testBasicSetMulti(TX_RB);
0608:            }
0609:
0610:            /**
0611:             * Add an element to a relation already multiple.
0612:             * Before: as1 -> bs1_1
0613:             *                bs0
0614:             * After:  as1 -> bs1_1
0615:             *         as1 -> bs0
0616:             */
0617:            public void _testBasicAddMulti(int tx) throws Exception {
0618:                ArrayList ce = (ArrayList) tbRelationA2B.get("as1");
0619:                if ((tx == TX_CALL) || (tx == TX_RB)) {
0620:                    utx.begin();
0621:                }
0622:                ARemote a = getAHome().findByPrimaryKey("as1");
0623:                if (tx == TX_CONT) {
0624:                    a.addInBInNewTx("bs0");
0625:                } else {
0626:                    a.addInB("bs0");
0627:                }
0628:                ce.add("bs0");
0629:                if (tx == TX_CALL) {
0630:                    utx.commit();
0631:                } else if (tx == TX_RB) {
0632:                    utx.rollback();
0633:                }
0634:                // checking
0635:                Collection ca = a.retrieveB();
0636:                if (tx == TX_RB)
0637:                    ce.remove("bs0");
0638:                try {
0639:                    assertTrue("Wrong relations as1 (required:" + ce
0640:                            + ", found:" + ca + ")", isCollectionEqual(ce, ca));
0641:                } finally {
0642:                    if (tx != TX_RB)
0643:                        ce.remove("bs0");
0644:                }
0645:                // undo
0646:                if (tx != TX_RB) {
0647:                    a.removeFromB("bs0");
0648:                    // Check undo
0649:                    ca = a.retrieveB();
0650:                    assertTrue("After undo, wrong relations: (required:"
0651:                            + tbRelationA2B.get("as1") + ", found:" + ca + ")",
0652:                            isCollectionEqual((Collection) tbRelationA2B
0653:                                    .get("as1"), ca));
0654:                }
0655:                checkIsInitialState();
0656:            }
0657:
0658:            public void testBasicAddMultiTxNo() throws Exception {
0659:                _testBasicAddMulti(TX_NO);
0660:            }
0661:
0662:            public void testBasicAddMultiTxCall() throws Exception {
0663:                _testBasicAddMulti(TX_CALL);
0664:            }
0665:
0666:            public void testBasicAddMultiTxCont() throws Exception {
0667:                _testBasicAddMulti(TX_CONT);
0668:            }
0669:
0670:            public void testBasicAddMultiTxRb() throws Exception {
0671:                _testBasicAddMulti(TX_RB);
0672:            }
0673:
0674:            /**
0675:             * Remove an element in a relation.
0676:             * Before: a3 -> b3_1
0677:             * Change: a3.retrieveB().remove(b3_1)
0678:             * After:  a3    b3_1
0679:             *
0680:             * See Spec chapter 10.3.7.4, change example: a1.getB().remove(b1n)
0681:             */
0682:            public void _testBasicRemoveInRel(int tx) throws Exception {
0683:                String bRemoved = "b3_1";
0684:                if ((tx == TX_CALL) || (tx == TX_RB)) {
0685:                    utx.begin();
0686:                }
0687:                ARemote a = getAHome().findByPrimaryKey("a3");
0688:                if (tx == TX_CONT) {
0689:                    a.removeFromBInNewTx(bRemoved);
0690:                } else {
0691:                    a.removeFromB(bRemoved);
0692:                }
0693:                if (tx == TX_CALL) {
0694:                    utx.commit();
0695:                } else if (tx == TX_RB) {
0696:                    utx.rollback();
0697:                }
0698:                // checking
0699:                Collection ca = a.retrieveB();
0700:                if (tx != TX_RB) {
0701:                    assertEquals("Wrong relations size for a3: ", 0, ca.size());
0702:                } else {
0703:                    assertEquals("Wrong relations size for a3: ", 1, ca.size());
0704:                }
0705:
0706:                // undo
0707:                if (tx != TX_RB) {
0708:                    a.addInB(bRemoved);
0709:                }
0710:                // check to initial state
0711:                checkIsInitialState();
0712:
0713:            }
0714:
0715:            public void testBasicRemoveInRelTxNo() throws Exception {
0716:                _testBasicRemoveInRel(TX_NO);
0717:            }
0718:
0719:            public void testBasicRemoveInRelTxCall() throws Exception {
0720:                _testBasicRemoveInRel(TX_CALL);
0721:            }
0722:
0723:            public void testBasicRemoveInRelTxCont() throws Exception {
0724:                _testBasicRemoveInRel(TX_CONT);
0725:            }
0726:
0727:            public void testBasicRemoveInRelTxRb() throws Exception {
0728:                _testBasicRemoveInRel(TX_RB);
0729:            }
0730:
0731:            /**
0732:             * Remove a bean B which is in a relation.
0733:             * Before: a3 -> b3_1
0734:             * change: B.remove(b3_1)
0735:             * After:  a3
0736:             */
0737:            public void _testCohRemove(int tx) throws Exception {
0738:                if (tx == TX_CONT) {
0739:                    // The transaction attribute of the remove method is TX_SUPPORT,
0740:                    // so the transaction cannot be initiate by the container
0741:                    fail("Transaction cannot be initiate by the container for this test");
0742:                }
0743:                String bRemoved = "b3_1";
0744:                if ((tx == TX_CALL) || (tx == TX_RB)) {
0745:                    utx.begin();
0746:                }
0747:                getBHome().remove(bRemoved);
0748:                if (tx == TX_CALL) {
0749:                    utx.commit();
0750:                } else if (tx == TX_RB) {
0751:                    utx.rollback();
0752:                }
0753:                // checking
0754:                ARemote a = getAHome().findByPrimaryKey("a3");
0755:                Collection ca = a.retrieveB();
0756:                if (tx != TX_RB) {
0757:                    assertEquals("Wrong relations size for a3: ", 0, ca.size());
0758:
0759:                    // undo
0760:                    getBHome().create(bRemoved);
0761:                    a.addInBInNewTx(bRemoved);
0762:                } else {
0763:                    assertEquals("Wrong relations size for a3: ", 1, ca.size());
0764:                }
0765:                // check to initial state
0766:                checkIsInitialState();
0767:            }
0768:
0769:            public void testCohRemoveTxNo() throws Exception {
0770:                _testCohRemove(TX_NO);
0771:            }
0772:
0773:            public void testCohRemoveTxCall() throws Exception {
0774:                _testCohRemove(TX_CALL);
0775:            }
0776:
0777:            public void testCohRemoveTxRb() throws Exception {
0778:                _testCohRemove(TX_RB);
0779:            }
0780:
0781:            /**
0782:             * Remove a bean B which is in a relation.
0783:             * Same as _testCohRemove except that the rcalled remove method is on the bean
0784:             * instead of the home.
0785:             * Before: a3 -> b3_1
0786:             * change: B.remove(b3_1)
0787:             * After:  a3
0788:             */
0789:            public void _testCohBeanRemove(int tx) throws Exception {
0790:                if (tx == TX_CONT) {
0791:                    // The transaction attribute of the remove method is TX_SUPPORT,
0792:                    // so the transaction cannot be initiate by the container
0793:                    fail("Transaction cannot be initiate by the container for this test");
0794:                }
0795:                String bRemoved = "b3_1";
0796:                if ((tx == TX_CALL) || (tx == TX_RB)) {
0797:                    utx.begin();
0798:                }
0799:                BRemote b = getBHome().findByPrimaryKey(bRemoved);
0800:                b.remove();
0801:                if (tx == TX_CALL) {
0802:                    utx.commit();
0803:                } else if (tx == TX_RB) {
0804:                    utx.rollback();
0805:                }
0806:                // checking
0807:                ARemote a = getAHome().findByPrimaryKey("a3");
0808:                Collection ca = a.retrieveB();
0809:                if (tx != TX_RB) {
0810:                    assertEquals("Wrong relations size for a3: ", 0, ca.size());
0811:
0812:                    // undo
0813:                    getBHome().create(bRemoved);
0814:                    a.addInBInNewTx(bRemoved);
0815:                } else {
0816:                    assertEquals("Wrong relations size for a3: ", 1, ca.size());
0817:                }
0818:                // check to initial state
0819:                checkIsInitialState();
0820:            }
0821:
0822:            public void testCohBeanRemoveTxNo() throws Exception {
0823:                _testCohBeanRemove(TX_NO);
0824:            }
0825:
0826:            public void testCohBeanRemoveTxCall() throws Exception {
0827:                _testCohBeanRemove(TX_CALL);
0828:            }
0829:
0830:            public void testCohBeanRemoveTxRb() throws Exception {
0831:                _testCohBeanRemove(TX_RB);
0832:            }
0833:
0834:            /**
0835:             * Set a empty relation with 1 element.
0836:             * This added element was already in a other relation.
0837:             * Before: a0
0838:             *         a3 -> b3_1
0839:             * Change: a0.assignB({b3_1})
0840:             * After:  a0 -> b3_1
0841:             *         a3
0842:             */
0843:            public void _testCohSetOne(int tx) throws Exception {
0844:                ArrayList ce = new ArrayList();
0845:                String bAdded = "b3_1";
0846:                ce.add(bAdded);
0847:                if ((tx == TX_CALL) || (tx == TX_RB)) {
0848:                    utx.begin();
0849:                }
0850:                ARemote a = getAHome().findByPrimaryKey("a0");
0851:                if (tx == TX_CONT) {
0852:                    a.assignBInNewTx(ce);
0853:                } else {
0854:                    a.assignB(ce);
0855:                }
0856:                if (tx == TX_CALL) {
0857:                    utx.commit();
0858:                } else if (tx == TX_RB) {
0859:                    utx.rollback();
0860:                }
0861:                // checking
0862:                Collection ca = a.retrieveB();
0863:                ARemote a3 = getAHome().findByPrimaryKey("a3");
0864:                Collection ca3 = a3.retrieveB();
0865:                if (tx != TX_RB) {
0866:                    assertTrue("Wrong relations a0 (required:" + ce
0867:                            + ", found:" + ca + ")", isCollectionEqual(ce, ca));
0868:                    assertTrue("Wrong relations for " + bAdded + ": found:"
0869:                            + ca3, !ca3.contains(bAdded));
0870:
0871:                    // undo
0872:                    a.assignB(new ArrayList());
0873:                    a3.addInB(bAdded);
0874:                    // Check undo
0875:                    ca = a.retrieveB();
0876:                    assertEquals("After undo, Relations size of: ", 0, ca
0877:                            .size());
0878:                } else {
0879:                    assertTrue("Wrong relations for " + bAdded + ": ", a3
0880:                            .containInB(bAdded));
0881:                }
0882:                checkIsInitialState();
0883:            }
0884:
0885:            public void testCohSetOneTxNo() throws Exception {
0886:                _testCohSetOne(TX_NO);
0887:            }
0888:
0889:            public void testCohSetOneTxCall() throws Exception {
0890:                _testCohSetOne(TX_CALL);
0891:            }
0892:
0893:            public void testCohSetOneTxCont() throws Exception {
0894:                _testCohSetOne(TX_CONT);
0895:            }
0896:
0897:            public void testCohSetOneTxRb() throws Exception {
0898:                _testCohSetOne(TX_RB);
0899:            }
0900:
0901:            /**
0902:             * Add an element to a relation already multiple.
0903:             * The element was already in a relation.
0904:             * Check also the assignement rules for relationships.
0905:             * Before: a1 -> b1_1
0906:             *            -> b1_2
0907:             *            -> b1_3
0908:             *         a3 -> b3_1
0909:             * Change: a1.addInB(b3_1)
0910:             * After:  a1 -> b1_1
0911:             *            -> b1_2
0912:             *            -> b1_3
0913:             *            -> b3_1
0914:             *         a3
0915:             *
0916:             * See Spec chapter 10.3.7.4, change example: a1.getB().add(b2m)
0917:             */
0918:            public void _testCohAddOneInMulti(int tx) throws Exception {
0919:                ArrayList ce = new ArrayList();
0920:                ce.add("b1_1");
0921:                ce.add("b1_2");
0922:                ce.add("b1_3");
0923:                String bAdded = "b3_1";
0924:                if ((tx == TX_CALL) || (tx == TX_RB)) {
0925:                    utx.begin();
0926:                }
0927:                ARemote a = getAHome().findByPrimaryKey("a1");
0928:                Collection co = a.retrieveB();
0929:                if (tx == TX_CONT) {
0930:                    a.addInBInNewTx(bAdded);
0931:                } else {
0932:                    a.addInB(bAdded);
0933:                }
0934:                ce.add(bAdded);
0935:                if (tx == TX_CALL) {
0936:                    utx.commit();
0937:                } else if (tx == TX_RB) {
0938:                    utx.rollback();
0939:                }
0940:                // checking
0941:                Collection ca = a.retrieveB();
0942:                ARemote a3 = getAHome().findByPrimaryKey("a3");
0943:                if (tx == TX_RB) {
0944:                    assertTrue("Wrong relations a1 (required:" + co
0945:                            + ", found:" + ca + ") (Rollback problem)",
0946:                            isCollectionEqual(co, ca));
0947:                    assertTrue("Wrong relations for " + bAdded
0948:                            + ": (coherence/rollback problem)", a3
0949:                            .containInB(bAdded));
0950:                } else {
0951:                    try {
0952:                        assertTrue("Wrong relations: ", isCollectionEqual(ce,
0953:                                ca));
0954:                        assertTrue("The added element (" + bAdded
0955:                                + ") is yet in the relation a3", !a3
0956:                                .containInB(bAdded));
0957:                    } finally {
0958:                        // undo
0959:                        a.removeFromB(bAdded);
0960:                        a3.addInB(bAdded);
0961:                    }
0962:                }
0963:                checkIsInitialState();
0964:            }
0965:
0966:            public void testCohAddOneInMultiTxNo() throws Exception {
0967:                _testCohAddOneInMulti(TX_NO);
0968:            }
0969:
0970:            public void testCohAddOneInMultiTxCall() throws Exception {
0971:                _testCohAddOneInMulti(TX_CALL);
0972:            }
0973:
0974:            public void testCohAddOneInMultiTxCont() throws Exception {
0975:                _testCohAddOneInMulti(TX_CONT);
0976:            }
0977:
0978:            public void testCohAddOneInMultiTxRb() throws Exception {
0979:                _testCohAddOneInMulti(TX_RB);
0980:            }
0981:
0982:            /**
0983:             * Add elements in an relationship.
0984:             * The relationship was not already empty.
0985:             * One element added had no relation, the other element had a relation
0986:             */
0987:            public void _testCohAddAllInMulti(int tx) throws Exception {
0988:                ArrayList c = new ArrayList();
0989:                c.add("b0");
0990:                c.add("b3_1");
0991:                if ((tx == TX_CALL) || (tx == TX_RB)) {
0992:                    utx.begin();
0993:                }
0994:                ARemote a = getAHome().findByPrimaryKey("a1");
0995:                Collection co = a.retrieveB();
0996:                if (tx == TX_CONT) {
0997:                    a.addAllInBInNewTx(c);
0998:                } else {
0999:                    a.addAllInB(c);
1000:                }
1001:                c.addAll(co); // c, added collection, becomes the expected collection
1002:                if (tx == TX_CALL) {
1003:                    utx.commit();
1004:                } else if (tx == TX_RB) {
1005:                    utx.rollback();
1006:                }
1007:                // checking
1008:                Collection ca = a.retrieveB();
1009:                ARemote a3 = getAHome().findByPrimaryKey("a3");
1010:                if (tx != TX_RB) {
1011:                    assertTrue("Wrong relations: ", isCollectionEqual(c, ca));
1012:                    assertTrue("Wrong relations for a3 ", !a3
1013:                            .containInB("b3_1"));
1014:                } else {
1015:                    assertTrue("Wrong relations: ", isCollectionEqual(co, ca));
1016:                    assertTrue("Wrong relations for a3 ", a3.containInB("b3_1"));
1017:                }
1018:                // undo
1019:                if (tx != TX_RB) {
1020:                    a.removeFromB("b0");
1021:                    a3.addInB("b3_1");
1022:                }
1023:                // check to initial
1024:                checkIsInitialState();
1025:
1026:            }
1027:
1028:            public void testCohAddAllInMultiTxNo() throws Exception {
1029:                _testCohAddAllInMulti(TX_NO);
1030:            }
1031:
1032:            public void testCohAddAllInMultiTxCall() throws Exception {
1033:                _testCohAddAllInMulti(TX_CALL);
1034:            }
1035:
1036:            public void testCohAddAllInMultiTxCont() throws Exception {
1037:                _testCohAddAllInMulti(TX_CONT);
1038:            }
1039:
1040:            public void testCohAddAllInMultiTxRb() throws Exception {
1041:                _testCohAddAllInMulti(TX_RB);
1042:            }
1043:
1044:            /*
1045:             * Set a relation to multiple.
1046:             * All of element was already in an other relation.
1047:             * Check also the assignement rules for relationships.
1048:             * Before: a1 -> b1_1
1049:             *            -> b1_2
1050:             *            -> b1_3
1051:             *         a2 -> b2_1
1052:             *            -> b2_2
1053:             *            -> b2_3
1054:             * Change: a1.assignB(a2.retrieveB())
1055:             * After:  a1 -> b2_1
1056:             *            -> b2_2
1057:             *            -> b2_3
1058:             *         a2
1059:             *               b1_1
1060:             *               b1_2
1061:             *               b1_3
1062:             *
1063:             * Spec chapter 10.3.7.4, change example: a1.setB(a2.getB())
1064:             */
1065:            public void _testCohSetMulti(int tx) throws Exception {
1066:                if ((tx == TX_CALL) || (tx == TX_RB)) {
1067:                    utx.begin();
1068:                }
1069:                ARemote a1 = getAHome().findByPrimaryKey("a1");
1070:                Collection co1 = a1.retrieveB();
1071:                ARemote a2 = getAHome().findByPrimaryKey("a2");
1072:                Collection co2 = a2.retrieveB();
1073:                if (tx == TX_CONT) {
1074:                    a1.assignBInNewTx(co2);
1075:                } else {
1076:                    a1.assignB(co2);
1077:                }
1078:                if (tx == TX_CALL) {
1079:                    utx.commit();
1080:                } else if (tx == TX_RB) {
1081:                    utx.rollback();
1082:                }
1083:                // checking
1084:                if (tx != TX_RB) {
1085:                    Collection ca1 = a1.retrieveB();
1086:                    assertTrue("Wrong relations for a1 (required:" + co2
1087:                            + ", found:" + ca1 + ")", isCollectionEqual(co2,
1088:                            ca1));
1089:                    Collection ca2 = a2.retrieveB();
1090:                    assertEquals("Wrong relations size for a2: ", 0, ca2.size());
1091:                    // Undo
1092:                    a1.assignB(co1);
1093:                    a2.assignB(co2);
1094:                }
1095:                checkIsInitialState();
1096:            }
1097:
1098:            public void testCohSetMultiTxNo() throws Exception {
1099:                _testCohSetMulti(TX_NO);
1100:            }
1101:
1102:            public void testCohSetMultiTxCall() throws Exception {
1103:                _testCohSetMulti(TX_CALL);
1104:            }
1105:
1106:            public void testCohSetMultiTxCont() throws Exception {
1107:                _testCohSetMulti(TX_CONT);
1108:            }
1109:
1110:            public void testCohSetMultiTxRb() throws Exception {
1111:                _testCohSetMulti(TX_RB);
1112:            }
1113:
1114:            /**
1115:             * Set a relation to multiple
1116:             * Some of element was already in this relation, other was in other relation,
1117:             * and other wasn't in any relation.
1118:             * Check also the assignement rules for relationships.
1119:             */
1120:            public void _testCohSetMultiVarious(int tx) throws Exception {
1121:                ArrayList ce = new ArrayList();
1122:                ce.add("b0");
1123:                ce.add("b1_2");
1124:                String b3Added = "b3_1";
1125:                ce.add(b3Added);
1126:                if ((tx == TX_CALL) || (tx == TX_RB)) {
1127:                    utx.begin();
1128:                }
1129:                ARemote a = getAHome().findByPrimaryKey("a1");
1130:                if (tx == TX_CONT) {
1131:                    a.assignBInNewTx(ce);
1132:                } else {
1133:                    a.assignB(ce);
1134:                }
1135:                if (tx == TX_CALL) {
1136:                    utx.commit();
1137:                } else if (tx == TX_RB) {
1138:                    utx.rollback();
1139:                }
1140:                // checking
1141:                Collection co = new ArrayList(3);
1142:                co.add("b1_1");
1143:                co.add("b1_2");
1144:                co.add("b1_3");
1145:                Collection ca = a.retrieveB();
1146:                ARemote a3 = getAHome().findByPrimaryKey("a3");
1147:                if (tx != TX_RB) {
1148:                    assertTrue("Wrong relations: ", isCollectionEqual(ce, ca));
1149:                    assertTrue("Wrong relations for " + b3Added + ": ", !a3
1150:                            .containInB(b3Added));
1151:
1152:                    //Undo
1153:                    a.assignB(co);
1154:                    a3.addInB(b3Added);
1155:                    // Check undo
1156:                    ca = a.retrieveB();
1157:                    if (!isCollectionEqual(co, ca)) {
1158:                        fail("After undo, wrong relations: expected:" + co
1159:                                + ", found:" + ca + ")");
1160:                    }
1161:                }
1162:                checkIsInitialState();
1163:            }
1164:
1165:            public void testCohSetMultiVariousTxNo() throws Exception {
1166:                _testCohSetMultiVarious(TX_NO);
1167:            }
1168:
1169:            public void testCohSetMultiVariousTxCall() throws Exception {
1170:                _testCohSetMultiVarious(TX_CALL);
1171:            }
1172:
1173:            public void testCohSetMultiVariousTxCont() throws Exception {
1174:                _testCohSetMultiVarious(TX_CONT);
1175:            }
1176:
1177:            public void testCohSetMultiVariousTxRb() throws Exception {
1178:                _testCohSetMultiVarious(TX_RB);
1179:            }
1180:
1181:            /**
1182:             * Test that a muti-valued cmr field is initialized to an empty collection after its creation.
1183:             * See spec. 2.0, & 10.5.5 page 171
1184:             */
1185:            public void _testCmrMultiIsInit(int tx) throws Exception {
1186:                if (tx == TX_CONT) {
1187:                    // The transaction attribute of the create method is TX_SUPPORT,
1188:                    // so the transaction cannot be initiate by the container
1189:                    fail("Transaction cannot be initiate by the container for this test");
1190:                }
1191:                if (tx == TX_RB) {
1192:                    fail("Transaction attribute 'TX_RB' has no sense for this test");
1193:                }
1194:                if (tx == TX_CALL) {
1195:                    utx.begin();
1196:                }
1197:                ARemote a = getAHome().create("aX");
1198:                if (tx == TX_CALL) {
1199:                    utx.commit();
1200:                }
1201:                // checking
1202:                Collection cb = a.retrieveB();
1203:                assertEquals(
1204:                        "The multi-valued cmr field 'b' not initialized with an empty collection",
1205:                        0, cb.size());
1206:                if (tx != TX_RB) {
1207:                    // undo
1208:                    a.remove();
1209:                }
1210:                // check to initial state
1211:                checkIsInitialState();
1212:            }
1213:
1214:            public void testCmrMultiIsInitTxNo() throws Exception {
1215:                _testCmrMultiIsInit(TX_NO);
1216:            }
1217:
1218:            public void testCmrMultiIsInitTxCall() throws Exception {
1219:                _testCmrMultiIsInit(TX_CALL);
1220:            }
1221:
1222:            public void testRepeatedAssign() throws Exception {
1223:                Collection co = new ArrayList(3);
1224:                co.add("b1_1");
1225:                co.add("b1_2");
1226:                co.add("b1_3");
1227:                ArrayList ce = new ArrayList();
1228:                ce.add("b0");
1229:                ce.add("b1_2");
1230:                String b3Added = "b3_1";
1231:                ce.add(b3Added);
1232:
1233:                ARemote a = getAHome().findByPrimaryKey("a1");
1234:                ARemote a3 = getAHome().findByPrimaryKey("a3");
1235:
1236:                utx.begin();
1237:                a.assignB(ce);
1238:                utx.commit();
1239:                a.assignB(co);
1240:                sync(false);
1241:                a.assignB(ce);
1242:
1243:                // undo
1244:                a.assignB(co);
1245:                a3.addInB(b3Added);
1246:                sync(false);
1247:                checkIsInitialState();
1248:            }
1249:
1250:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.