1 5 package org.h2.test; 6 7 import java.sql.SQLException ; 8 import java.util.Properties ; 9 10 import org.h2.server.TcpServer; 11 import org.h2.test.jdbc.*; 12 import org.h2.test.db.*; 13 import org.h2.test.server.TestNestedLoop; 14 import org.h2.test.synth.TestBtreeIndex; 15 import org.h2.test.synth.TestCrashAPI; 16 import org.h2.test.synth.TestHaltApp; 17 import org.h2.test.synth.TestJoin; 18 import org.h2.test.synth.TestKill; 19 import org.h2.test.synth.TestMulti; 20 import org.h2.test.synth.TestRandomSQL; 21 import org.h2.test.synth.TestSynth; 22 import org.h2.test.unit.TestBitField; 23 import org.h2.test.unit.TestCache; 24 import org.h2.test.unit.TestCompress; 25 import org.h2.test.unit.TestDataPage; 26 import org.h2.test.unit.TestExit; 27 import org.h2.test.unit.TestFileLock; 28 import org.h2.test.unit.TestIntArray; 29 import org.h2.test.unit.TestIntIntHashMap; 30 import org.h2.test.unit.TestOverflow; 31 import org.h2.test.unit.TestPattern; 32 import org.h2.test.unit.TestReader; 33 import org.h2.test.unit.TestSampleApps; 34 import org.h2.test.unit.TestScriptReader; 35 import org.h2.test.unit.TestSecurity; 36 import org.h2.test.unit.TestStreams; 37 import org.h2.test.unit.TestStringCache; 38 import org.h2.test.unit.TestStringUtils; 39 import org.h2.test.unit.TestTools; 40 import org.h2.test.unit.TestValueHashMap; 41 import org.h2.tools.DeleteDbFiles; 42 import org.h2.tools.Server; 43 import org.h2.util.StringUtils; 44 45 48 public class TestAll { 49 50 56 73 74 public boolean smallLog, big, networked, memory, ssl, textStorage, diskUndo, diskResult, deleteIndex, traceSystemOut; 75 public boolean codeCoverage; 76 public int logMode = 1, traceLevelFile, throttle; 77 public String cipher; 78 79 public boolean traceTest, stopOnError; 80 public boolean jdk14 = true; 81 82 private Server server; 83 84 public static void main(String [] args) throws Exception { 85 long time = System.currentTimeMillis(); 86 TestAll test = new TestAll(); 87 test.printSystem(); 88 89 92 98 103 115 124 128 130 132 139 141 if(args.length>0) { 142 if("crash".equals(args[0])) { 143 new TestCrashAPI().runTest(test); 144 } else if("synth".equals(args[0])) { 145 new TestSynth().runTest(test); 146 } else if("kill".equals(args[0])) { 147 new TestKill().runTest(test); 148 } else if("random".equals(args[0])) { 149 new TestRandomSQL().runTest(test); 150 } else if("join".equals(args[0])) { 151 new TestJoin().runTest(test); 152 } else if("btree".equals(args[0])) { 153 new TestBtreeIndex().runTest(test); 154 } else if("all".equals(args[0])) { 155 test.testEverything(); 156 } else if("codeCoverage".equals(args[0])) { 157 test.testCodeCoverage(); 158 } else if("multiThread".equals(args[0])) { 159 new TestMulti().runTest(test); 160 } else if("halt".equals(args[0])) { 161 new TestHaltApp().runTest(test); 162 } 163 } else { 164 test.runTests(); 165 } 166 System.out.println("done ("+(System.currentTimeMillis()-time)+" ms)"); 167 } 168 169 void runTests() throws Exception { 170 171 174 179 181 187 188 189 195 testQuick(); 196 testCombination(); 197 198 } 199 200 void testCodeCoverage() throws Exception { 201 this.codeCoverage = true; 202 runTests(); 203 } 204 205 void testQuick() throws Exception { 206 smallLog = big = networked = memory = ssl = textStorage = diskResult = deleteIndex = traceSystemOut = diskUndo = false; 207 traceLevelFile = throttle = 0; 208 logMode = 1; 209 cipher = null; 210 testAll(); 211 } 212 213 void testEverything() throws Exception { 214 for(int c = 0; c < 3; c++) { 215 if(c == 0) { 216 cipher = null; 217 } else if(c==1) { 218 cipher = "XTEA"; 219 } else { 220 cipher = "AES"; 221 } 222 for(int a = 0; a < 256; a++) { 223 smallLog = (a & 1) != 0; 224 big = (a & 2) != 0; 225 networked = (a & 4) != 0; 226 memory = (a & 8) != 0; 227 ssl = (a & 16) != 0; 228 textStorage = (a & 32) != 0; 229 diskResult = (a & 64) != 0; 230 deleteIndex = (a & 128) != 0; 231 for(logMode = 0; logMode < 3; logMode++) { 232 traceLevelFile = logMode; 233 TestBase.printTime("cipher:" + cipher +" a:" +a+" logMode:"+logMode); 234 testAll(); 235 } 236 } 237 } 238 } 239 240 void testCombination() throws Exception { 241 smallLog = big = networked = memory = ssl = textStorage = diskResult = deleteIndex = traceSystemOut = false; 242 traceLevelFile = throttle = 0; 243 logMode = 1; 244 cipher = null; 245 testAll(); 246 247 diskUndo = false; 248 smallLog = false; 249 big = false; 250 networked = true; 251 memory = true; 252 ssl = false; 253 textStorage = true; 254 diskResult = deleteIndex = traceSystemOut = false; 255 traceLevelFile = throttle = 0; 256 logMode = 1; 257 cipher = null; 258 testAll(); 259 260 big = false; 261 smallLog = false; 262 networked = false; 263 memory = false; 264 ssl = false; 265 textStorage = false; 266 diskResult = false; 267 deleteIndex = false; 268 traceSystemOut = false; 269 logMode = 2; 270 traceLevelFile = 0; 271 throttle = 0; 272 cipher = null; 273 testAll(); 274 275 diskUndo = true; 276 smallLog = false; 277 big = networked = memory = ssl = false; 278 textStorage = true; 279 diskResult = true; 280 deleteIndex = true; 281 traceSystemOut = false; 282 logMode = 1; 283 traceLevelFile = 3; 284 throttle = 1; 285 cipher = "XTEA"; 286 testAll(); 287 288 diskUndo = false; 289 big = true; 290 smallLog = false; 291 networked = false; 292 memory = false; 293 ssl = false; 294 textStorage = false; 295 diskResult = false; 296 deleteIndex = false; 297 traceSystemOut = false; 298 logMode = 1; 299 traceLevelFile = 1; 300 throttle = 0; 301 cipher = null; 302 testAll(); 303 304 big = true; 305 smallLog = true; 306 networked = true; 307 memory = false; 308 ssl = true; 309 textStorage = false; 310 diskResult = false; 311 deleteIndex = false; 312 traceSystemOut = false; 313 logMode = 2; 314 traceLevelFile = 2; 315 throttle = 0; 316 cipher = null; 317 testAll(); 318 319 big = true; 320 smallLog = false; 321 networked = true; 322 memory = false; 323 ssl = false; 324 textStorage = false; 325 diskResult = false; 326 deleteIndex = false; 327 traceSystemOut = false; 328 logMode = 0; 329 traceLevelFile = 0; 330 throttle = 0; 331 cipher = "AES"; 332 testAll(); 333 334 } 335 336 void testAll() throws Exception { 337 DeleteDbFiles.execute(TestBase.BASE_DIR, null, true); 338 testDatabase(); 339 testUnit(); 340 DeleteDbFiles.execute(TestBase.BASE_DIR, null, true); 341 } 342 343 void testUnit() { 344 new TestBitField().runTest(this); 345 new TestCompress().runTest(this); 346 new TestDataPage().runTest(this); 347 new TestExit().runTest(this); 348 new TestFileLock().runTest(this); 349 new TestIntArray().runTest(this); 350 new TestIntIntHashMap().runTest(this); 351 new TestOverflow().runTest(this); 352 new TestPattern().runTest(this); 353 new TestReader().runTest(this); 354 new TestSampleApps().runTest(this); 355 new TestScriptReader().runTest(this); 356 new TestSecurity().runTest(this); 357 new TestStreams().runTest(this); 358 new TestStringCache().runTest(this); 359 new TestStringUtils().runTest(this); 360 new TestTools().runTest(this); 361 new TestValueHashMap().runTest(this); 362 } 363 364 void testDatabase() throws Exception { 365 System.out.println("test big:"+big+" net:"+networked+" cipher:"+cipher+" memory:"+memory+" log:"+logMode+" diskResult:"+diskResult); 366 beforeTest(); 367 368 new TestScriptSimple().runTest(this); 370 new TestScript().runTest(this); 371 new TestAutoRecompile().runTest(this); 372 new TestBatchUpdates().runTest(this); 373 new TestBigDb().runTest(this); 374 new TestBigResult().runTest(this); 375 new TestCache().runTest(this); 376 new TestCases().runTest(this); 377 new TestCheckpoint().runTest(this); 378 new TestCluster().runTest(this); 379 new TestCompatibility().runTest(this); 380 new TestCsv().runTest(this); 381 new TestFunctions().runTest(this); 382 new TestIndex().runTest(this); 383 new TestLinkedTable().runTest(this); 384 new TestListener().runTest(this); 385 new TestLob().runTest(this); 386 new TestLogFile().runTest(this); 387 new TestMemoryUsage().runTest(this); 388 new TestMultiConn().runTest(this); 389 new TestMultiDimension().runTest(this); 390 new TestMultiThread().runTest(this); 391 new TestOpenClose().runTest(this); 392 new TestOptimizations().runTest(this); 393 new TestPowerOff().runTest(this); 394 new TestReadOnly().runTest(this); 395 new TestRights().runTest(this); 396 new TestRunscript().runTest(this); 397 new TestSQLInjection().runTest(this); 398 new TestSequence().runTest(this); 399 new TestSpaceReuse().runTest(this); 400 new TestSpeed().runTest(this); 401 new TestTempTables().runTest(this); 402 new TestTransaction().runTest(this); 403 new TestTriggersConstraints().runTest(this); 404 new TestTwoPhaseCommit().runTest(this); 405 406 new TestNestedLoop().runTest(this); 408 409 new TestCancel().runTest(this); 411 new TestDataSource().runTest(this); 412 new TestManyJdbcObjects().runTest(this); 413 new TestMetaData().runTest(this); 414 new TestNativeSQL().runTest(this); 415 new TestPreparedStatement().runTest(this); 416 new TestResultSet().runTest(this); 417 new TestStatement().runTest(this); 418 new TestTransactionIsolation().runTest(this); 419 new TestUpdatableResultSet().runTest(this); 420 new TestZloty().runTest(this); 421 422 afterTest(); 423 } 424 425 public void beforeTest() throws SQLException { 426 if(networked) { 427 TcpServer.LOG_INTERNAL_ERRORS = true; 428 String [] args = ssl ? new String []{"-tcpSSL", "true"} : new String [0]; 429 server = Server.createTcpServer(args); 430 try { 431 server.start(); 432 } catch(SQLException e) { 433 System.out.println("FAIL: can not start server (may already be running)"); 434 server = null; 435 } 436 } 437 } 438 439 public void afterTest() { 440 if(networked && server != null) { 441 server.stop(); 442 } 443 } 444 445 private void printSystem() { 446 Properties prop = System.getProperties(); 447 System.out.println("Java: " + 448 prop.getProperty("java.runtime.version") + ", " + 449 prop.getProperty("java.vm.name")+", " + 450 prop.getProperty("java.vendor")); 451 System.out.println("Env: " + 452 prop.getProperty("os.name") + ", " + 453 prop.getProperty("os.arch")+", "+ 454 prop.getProperty("os.version")+", "+ 455 prop.getProperty("sun.os.patch.level")+", "+ 456 prop.getProperty("file.separator")+" "+ 457 prop.getProperty("path.separator")+" "+ 458 StringUtils.javaEncode( prop.getProperty("line.separator"))+" "+ 459 prop.getProperty("user.country") + " " + 460 prop.getProperty("user.language") + " " + 461 prop.getProperty("user.variant")+" "+ 462 prop.getProperty("file.encoding")); 463 } 464 } 465 | Popular Tags |