1 24 package org.objectweb.jalisto.test.core.suite; 25 26 import junit.framework.Test; 27 import org.objectweb.jalisto.se.test.data.Book; 28 import org.objectweb.jalisto.se.test.workbench.JalistoTestCase; 29 import org.objectweb.jalisto.se.test.workbench.JalistoTestSuite; 30 import org.objectweb.jalisto.se.api.internal.SessionInternal; 31 import org.objectweb.jalisto.se.api.ClassDescription; 32 import org.objectweb.jalisto.se.JalistoFactory; 33 import org.objectweb.jalisto.se.impl.LogicalOid; 34 import org.objectweb.jalisto.se.impl.meta.type.MetaTypeFactory; 35 36 public class PopulateTestCase extends JalistoTestCase { 37 public PopulateTestCase() { 38 } 39 40 public PopulateTestCase(String name) { 41 super(name); 42 } 43 44 public static Test suite() { 45 JalistoTestSuite suite = new JalistoTestSuite(); 46 PopulateTestCase tc = (PopulateTestCase) newTestCase(suite, new PopulateTestCase()); 47 48 tc.define(); 49 tc.cleanUp(); 50 51 tc.populate(500); 53 tc.eraseTest(); 54 55 57 tc.finishTests(); 58 59 return suite; 60 } 61 62 public void eraseTest() { 63 session.closeSession(); 64 session.eraseStorage(); 65 SessionInternal internal = (SessionInternal) session; 66 long[] floids = internal.getOidTable().getIdentityProvider().getFloidCounters(); 67 for (int i = 0; i < floids.length; i++) { 68 assertEquals("must be null", 0, floids[i]); 69 } 70 short clid = internal.getOidTable().getIdentityProvider().getClidCounter(); 71 assertEquals("must be empty", -1, clid); 72 session.openSession(); 73 } 74 75 public void overheadFloids() { 76 boolean continueTest = true; 77 String className = "java.Vomir"; 78 Object [] data = new Object [2]; 79 data[0] = "tralala"; 80 data[1] = new Integer (465); 81 int c = 0; 82 while(continueTest) { 83 try { 84 ClassDescription meta = JalistoFactory.createClassDescription(className+c); 85 meta.addField(JalistoFactory.createFieldDescription("title", MetaTypeFactory.StringType)); 86 meta.addField(JalistoFactory.createFieldDescription("pages", MetaTypeFactory.IntegerType)); 87 session.defineClass(meta); 88 tx.begin(); 89 LogicalOid floid = (LogicalOid) session.createObject(data, className+c); 90 assertEquals("must be equals", c, floid.getClid()); 91 assertEquals("must be equals", 0, floid.getInstanceNumber()); 92 assertTrue("must be > 0, c = "+c, floid.getFloidAsLong() >= 0); 93 tx.commit(); 94 } catch (Exception e) { 95 continueTest = false; 96 System.out.println("c = "+c); 97 System.out.println(e.getMessage()); 98 } 99 if ((c % 100) == 0) { 100 System.out.println("c = "+c); 101 } 102 c++; 103 } 104 } 105 106 109 110 public void define() { 111 super.initSession(false); 112 super.define(Book.getMetaDescription()); 113 } 114 115 public void cleanUp() { 116 super.cleanUp(Book.class); 117 } 118 119 public void populate(int nbr) { 120 super.populate(nbr); 121 } 122 123 public void finishTests() { 124 super.finishTests(); 125 } 126 } 127 | Popular Tags |