1 21 22 package org.opensubsystems.core.persist.db; 23 24 import junit.extensions.TestSetup; 25 import junit.framework.Test; 26 27 import org.opensubsystems.core.error.OSSException; 28 import org.opensubsystems.core.util.Config; 29 30 93 public class DatabaseTestSetup extends TestSetup 94 { 95 97 100 protected static final String DEFAULT_PROPERTY_FILE = "osstest.properties"; 101 102 104 107 static 108 { 109 if (Config.getInstance().getPropertyFileName() == null) 110 { 111 Config.getInstance().setPropertyFileName(DEFAULT_PROPERTY_FILE); 112 } 113 } 114 115 120 public DatabaseTestSetup( 121 Test test 122 ) 123 { 124 super(test); 125 } 126 127 132 protected void setUp( 133 ) throws Exception 134 { 135 super.setUp(); 136 137 try 138 { 139 Database dbDefaultDB; 142 143 dbDefaultDB = DatabaseImpl.getInstance(); 144 if (dbDefaultDB != null) 145 { 146 dbDefaultDB.start(); 147 } 148 } 149 catch (OSSException osseExc) 150 { 151 throw new Exception ("Cannot start database.", osseExc); 152 } 153 } 154 155 160 protected void tearDown( 161 ) throws Exception 162 { 163 try 164 { 165 Database dbDefaultDB; 168 169 dbDefaultDB = DatabaseImpl.getInstance(); 170 if (dbDefaultDB != null) 171 { 172 dbDefaultDB.stop(); 173 } 174 } 175 catch (OSSException bfeExc) 176 { 177 throw new RuntimeException ("Cannot stop database.", bfeExc); 178 } 179 180 super.tearDown(); 181 } 182 } 183 | Popular Tags |