1 24 25 package org.objectweb.cjdbc.scenario.raidb0; 26 27 import java.sql.Connection ; 28 29 import org.objectweb.cjdbc.scenario.templates.SimpleRaidb0Template; 30 import org.objectweb.cjdbc.scenario.tools.ScenarioUtility; 31 32 38 public class Raidb0CheckSchemaScenario extends SimpleRaidb0Template 39 { 40 41 46 public void testSchemaRaidb0() throws Exception 47 { 48 cm.loadVirtualDatabases(controller, "myDB", 49 "hsqldb-raidb0-randomwaitpool.xml"); 50 deepTestSchema(); 51 } 52 53 private void deepTestSchema() throws Exception 54 { 55 mainVdb = controller.getVirtualDatabase("myDB"); 56 Connection con = getCJDBCConnection(); 57 58 testTheSchema(con, new boolean[]{true, true, true, true, true}); 59 mainVdb.forceDisableBackend("localhost"); 61 testTheSchema(con, new boolean[]{true, true, true, false, false}); 62 ScenarioUtility.displayResultOnScreen(con.getMetaData().getTables(null, 63 null, null, null)); 64 mainVdb.forceEnableBackend("localhost"); 65 testTheSchema(con, new boolean[]{true, true, true, true, true}); 66 mainVdb.forceDisableBackend("localhost2"); 68 testTheSchema(con, new boolean[]{false, false, false, true, true}); 69 ScenarioUtility.displayResultOnScreen(con.getMetaData().getTables(null, 70 null, null, null)); 71 mainVdb.forceEnableBackend("localhost2"); 72 testTheSchema(con, new boolean[]{true, true, true, true, true}); 73 ScenarioUtility.displayResultOnScreen(con.getMetaData().getTables(null, 74 null, null, null)); 75 } 76 77 private void testTheSchema(Connection con, boolean[] success) 78 throws Exception 79 { 80 testTheTable(con, "DOCUMENT", success[0]); 81 testTheTable(con, "BLOB", success[1]); 82 testTheTable(con, "PPOSITION", success[2]); 83 testTheTable(con, "PRODUCT", success[3]); 84 testTheTable(con, "ADDRESS", success[4]); 85 } 86 87 private void testTheTable(Connection con, String table, boolean assertTrue) 88 { 89 try 90 { 91 ScenarioUtility.getSingleQueryResult("select * from " + table, con); 92 } 95 catch (Exception e) 96 { 97 e.printStackTrace(); 98 if (assertTrue) 99 fail("success was expected on table:" + table); 100 } 101 } 102 } | Popular Tags |