1 18 19 package org.objectweb.speedo.stress; 20 21 import javax.jdo.JDOFatalException; 22 import javax.jdo.PersistenceManager; 23 24 import org.objectweb.speedo.pobjects.relations.A; 25 import org.objectweb.speedo.pobjects.relations.B; 26 27 32 public class TestRelation1_1 extends StressHelper { 33 34 public TestRelation1_1(String s) { 35 super(s); 36 } 37 38 protected String [] getClassNamesToInit() { 39 return new String []{ 40 org.objectweb.speedo.pobjects.relations.A.class.getName(), 41 org.objectweb.speedo.pobjects.relations.B.class.getName() 42 }; 43 } 44 45 protected String getLoggerName() { 46 return STRESS_LOG_NAME + ".TestRelation1_1"; 47 } 48 49 50 protected void perform(StressHelper.Task task, 51 int threadId, 52 int txId, 53 Object ctx, 54 StressHelper.PerformResult res) { 55 PersistenceManager pm = getPM(task, threadId, txId); 56 try { 57 res.beginTest(); 58 int oid = txId * 2; 59 beginTx(pm, task, threadId, txId); 60 A a1 = new A("a" + oid); 62 A a2 = new A("a" + oid + 1); 63 B b1 = new B("b" + oid); 64 B b2 = new B("b" + oid + 1); 65 pm.makePersistent(a1); 66 pm.makePersistent(a2); 67 pm.makePersistent(b1); 68 pm.makePersistent(b2); 69 commitTx(pm, task, threadId, txId); 70 71 a1.setB(b1); 72 assertTrue(b1.getA() == a1); 73 a2.setB(b2); 74 assertTrue(b2.getA() == a2); 75 a1.setB(b2); 76 assertTrue(b1.getA() == null); 77 assertTrue(b2.getA() == a1); 78 assertTrue(a2.getB() == null); 79 b1.setA(a2); 80 assertTrue(a2.getB() == b1); 81 b1.setA(a1); 82 assertTrue(a1.getB() == b1); 83 assertTrue(b2.getA() == null); 84 assertTrue(a2.getB() == null); 85 86 beginTx(pm, task, threadId, txId); 88 pm.deletePersistent(a1); 89 pm.deletePersistent(a2); 90 pm.deletePersistent(b1); 91 pm.deletePersistent(b2); 92 commitTx(pm, task, threadId, txId); 93 94 res.endTest(); 95 } catch (JDOFatalException e) { 96 rollbackOnException(pm, e, res, task, threadId, txId); 97 } catch (Throwable e) { 98 stopOnError(pm, e, res, task, threadId, txId); 99 } finally { 100 closePM(pm, threadId, txId, task, res); 101 } 102 } 103 104 108 public void testRelation1_1() { 109 if (interactive) { 110 perform(Integer.getInteger(THREAD, 1).intValue(), 111 Integer.getInteger(TX, 1).intValue(), 112 Integer.getInteger(TIMEOUT, 1).intValue(), null); 113 } 114 } 115 116 119 public void testRelation1_1Th1Tx100() { 120 if (!interactive) { 121 perform(1, 100, 1000000, null); 122 } 123 } 124 125 128 public void testRelation1_1Th1Tx1000() { 129 if (!interactive) { 130 perform(1, 1000, 1000000, null); 131 } 132 } 133 134 137 public void testRelation1_1Th1Tx10000() { 138 if (!interactive) { 139 perform(1, 10000, 1000000, null); 140 } 141 } 142 143 146 public void testRelation1_1Th2Tx100() { 147 if (!interactive) { 148 perform(2, 100, 1000000, null); 149 } 150 } 151 152 155 public void testRelation1_1Th2Tx1000() { 156 if (!interactive) { 157 perform(2, 1000, 1000000, null); 158 } 159 } 160 161 164 public void testRelation1_1Th2Tx10000() { 165 if (!interactive) { 166 perform(2, 10000, 1000000, null); 167 } 168 } 169 170 173 public void testRelation1_1Th10Tx100() { 174 if (!interactive) { 175 perform(10, 100, 1000000, null); 176 } 177 } 178 179 182 public void testRelation1_1Th10Tx1000() { 183 if (!interactive) { 184 perform(10, 1000, 1000000, null); 185 } 186 } 187 188 191 public void testRelation1_1Th10Tx10000() { 192 if (!interactive) { 193 perform(10, 10000, 1000000, null); 194 } 195 } 196 } 197 | Popular Tags |