|
From: <pe...@us...> - 2003-12-26 22:51:21
|
Update of /cvsroot/neuclear/neuclear-commons/src/test/org/neuclear/commons/sql/entities In directory sc8-pr-cvs1:/tmp/cvs-serv2763/src/test/org/neuclear/commons/sql/entities Modified Files: TableDefinitionTest.java Log Message: Mainly fixes to SQLLedger to support the schema generated by the new EntityModel Index: TableDefinitionTest.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-commons/src/test/org/neuclear/commons/sql/entities/TableDefinitionTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TableDefinitionTest.java 24 Dec 2003 00:25:41 -0000 1.1 --- TableDefinitionTest.java 26 Dec 2003 22:51:17 -0000 1.2 *************** *** 4,7 **** --- 4,8 ---- import org.neuclear.commons.sql.ConnectionSource; import org.neuclear.commons.sql.DefaultConnectionSource; + import org.neuclear.commons.sql.TestCaseConnectionSource; import org.neuclear.commons.NeuClearException; import org.neuclear.commons.time.TimeTools; *************** *** 33,36 **** --- 34,40 ---- $Id$ $Log$ + Revision 1.2 2003/12/26 22:51:17 pelle + Mainly fixes to SQLLedger to support the schema generated by the new EntityModel + Revision 1.1 2003/12/24 00:25:41 pelle Created a kind of poor man's version of ofbiz.org's EntityEngine. It doesnt use xml to configure it, but code. *************** *** 68,78 **** table.addComment(); String correct="CREATE TABLE transaction (\n" + ! "id BIGINT,\n" + ! "valuetime TIMESTAMP,\n" + "from VARCHAR(50),\n" + "to VARCHAR(50),\n" + "amount DECIMAL,\n" + ! "comment VARCHAR(100),\n" + ! "PRIMARY KEY(id)\n)"; System.out.println(table.createDDL()); assertEquals(correct,table.createDDL()); --- 72,82 ---- table.addComment(); String correct="CREATE TABLE transaction (\n" + ! "id IDENTITY,\n" + ! "created TIMESTAMP,\n" + "from VARCHAR(50),\n" + "to VARCHAR(50),\n" + "amount DECIMAL,\n" + ! "comment VARCHAR(100)\n" + ! ")"; System.out.println(table.createDDL()); assertEquals(correct,table.createDDL()); *************** *** 87,92 **** table.addComment(); String correct="CREATE TABLE transaction (\n" + ! "id BIGINT,\n" + ! "valuetime TIMESTAMP,\n" + "sender VARCHAR(50),\n" + "to VARCHAR(50),\n" + --- 91,96 ---- table.addComment(); String correct="CREATE TABLE transaction (\n" + ! "id IDENTITY,\n" + ! "created TIMESTAMP,\n" + "sender VARCHAR(50),\n" + "to VARCHAR(50),\n" + *************** *** 95,101 **** "FOREIGN KEY (sender) REFERENCES accounts(id) ON DELETE CASCADE,\n" + // "INDEX fromidx (from),\n" + ! "FOREIGN KEY (to) REFERENCES accounts(id) ON DELETE CASCADE,\n" + // "INDEX toidx (to),\n" + ! "PRIMARY KEY(id)\n)"; System.out.println(table.createDDL()); assertEquals(correct,table.createDDL()); --- 99,105 ---- "FOREIGN KEY (sender) REFERENCES accounts(id) ON DELETE CASCADE,\n" + // "INDEX fromidx (from),\n" + ! "FOREIGN KEY (to) REFERENCES accounts(id) ON DELETE CASCADE\n" + // "INDEX toidx (to),\n" + ! ")"; System.out.println(table.createDDL()); assertEquals(correct,table.createDDL()); *************** *** 103,108 **** public void testCreateTableStructure() throws SQLException, IOException, NamingException, NeuClearException { ! EntityModel accounts=new EntityModel("accounts", true); ! EntityModel table=new EntityModel("transaction", false); table.addTimeStamp(); table.addReference("sender",accounts); --- 107,122 ---- public void testCreateTableStructure() throws SQLException, IOException, NamingException, NeuClearException { ! final Connection con = new TestCaseConnectionSource().getConnection(); ! try { ! PreparedStatement stmt=con.prepareStatement("drop testtransaction"); ! stmt.execute(); ! stmt=con.prepareStatement("drop testaccounts"); ! stmt.execute(); ! } catch (Exception e) { ! ; ! } ! ! EntityModel accounts=new EntityModel("testaccounts", true); ! EntityModel table=new EntityModel("testtransaction", false); table.addTimeStamp(); table.addReference("sender",accounts); *************** *** 110,118 **** table.addMoney(); table.addComment(); - final Connection con = new DefaultConnectionSource().getConnection(); table.create(con); Entity entity=table.insertEntity(con,new Object[] { ! "id",new Long(new Random().nextLong()), ! "valuetime",TimeTools.now(), "sender",new Object[]{ "id","neu://bob@test" --- 124,130 ---- table.addMoney(); table.addComment(); table.create(con); Entity entity=table.insertEntity(con,new Object[] { ! "created",TimeTools.now(), "sender",new Object[]{ "id","neu://bob@test" |