|
@@ -1,80 +1,80 @@ |
1 |
|
- |
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
|
- |
package org.litesoft.or; |
3 |
|
- |
|
4 |
|
- |
import org.litesoft.configuration.*; |
5 |
|
- |
import org.litesoft.core.*; |
6 |
|
- |
import org.litesoft.logger.*; |
7 |
|
- |
import org.litesoft.logger.nonpublic.*; |
8 |
|
- |
import org.litesoft.loggerconfig.*; |
9 |
|
- |
import org.litesoft.orsup.base.*; |
10 |
|
- |
import org.litesoft.orsup.nonpublic.*; |
11 |
|
- |
import org.litesoft.sql.*; |
12 |
|
- |
|
13 |
|
- |
public class TestSupport { |
14 |
|
- |
public static final String[] NON_JDBC_CONFIGURATION = // |
15 |
|
- |
{ // |
16 |
|
- |
// Block Sizing (HI/LOW) |
17 |
|
- |
"blocksize", "100", // |
18 |
|
- |
"objectID.blocksize", "10", // |
19 |
|
- |
// |
20 |
|
- |
LoggerLevel.CONFIGURATION_BASE, "Warn", // |
21 |
|
- |
// |
22 |
|
- |
// Add Specific Logging below: |
23 |
|
- |
// "LoggingLevel.org.litesoft.sql.statements.JDBCexecutor", "TRACE", // |
24 |
|
- |
// "LoggingLevel.org.litesoft.sql.statements.JDBCexecutor", "DEBUG", // |
25 |
|
- |
// LoggerLevel.CONFIGURATION_BASE + ".org.litesoft.sql.statements.JDBCexecuteQuery", "Debug", // |
26 |
|
- |
// LoggerLevel.CONFIGURATION_BASE + ".org.litesoft.sql.statements.JDBCexecutorNonQuery", "Debug", // |
27 |
|
- |
}; |
28 |
|
- |
|
29 |
|
- |
public static final String[] HSQL_CONFIGURATION = // |
30 |
|
- |
{ // |
31 |
|
- |
// JDBC HSQL stuff: |
32 |
|
- |
"databaseDriverClassName", "org.hsqldb.jdbcDriver", // |
33 |
|
- |
"databaseURL", "jdbc:hsqldb:mem:test_pos", // |
34 |
|
- |
"databaseUserName", "sa", // |
35 |
|
- |
// "databaseUserPassword", "georges", // |
36 |
|
- |
// "databaseConnectionPoolSize", "200", // |
37 |
|
- |
// "databaseConnectionPoolDisable", "true", // |
38 |
|
- |
}; |
39 |
|
- |
|
40 |
|
- |
public static void initializeConfiguration() { |
41 |
|
- |
if ( !Configuration.isInstantiated() ) { |
42 |
|
- |
new ServerConfiguration( new MapConfigDataAccessorFactory( NON_JDBC_CONFIGURATION, "Memory", |
43 |
|
- |
HSQL_CONFIGURATION ) ); // force creation & self registration of Configuration |
44 |
|
- |
LoggerFactory.init( new ConfigurationLoggerLevel() ); |
45 |
|
- |
} |
46 |
|
- |
} |
47 |
|
- |
|
48 |
|
- |
public static void beforeClass( MetaDataRegistry pRegistry ) |
49 |
|
- |
throws Exception { |
50 |
|
- |
try { |
51 |
|
- |
initializeConfiguration(); |
52 |
|
- |
DataStoreLocator.uninitialize(); |
53 |
|
- |
DataStoreBaseSQL zMasterDataStore = new DataStoreBaseSQL( pRegistry ); |
54 |
|
- |
DataStoreLocator.initialize( zMasterDataStore ); |
55 |
|
- |
|
56 |
|
- |
new DemoDataStoreManager( zMasterDataStore, pRegistry, 10 ); |
57 |
|
- |
} |
58 |
|
- |
catch ( Throwable e ) { |
59 |
|
- |
System.out.println( "failed in beforeClass for SampleTest " + e ); |
60 |
|
- |
throw new RuntimeException( e ); |
61 |
|
- |
} |
62 |
|
- |
} |
63 |
|
- |
|
64 |
|
- |
public static void afterClass() { |
65 |
|
- |
DataStore zDataStore = DataStoreLocator.get(); |
66 |
|
- |
if ( zDataStore != null ) { |
67 |
|
- |
zDataStore.dropAllTables(); |
68 |
|
- |
DataStoreLocator.uninitialize(); |
69 |
|
- |
} |
70 |
|
- |
} |
71 |
|
- |
|
72 |
|
- |
public static void beforeTest() { |
73 |
|
- |
ServerContext.clearAllServerStores(); |
74 |
|
- |
|
75 |
|
- |
ContextID zContextID = new ContextID( "Test", "Test" ); |
76 |
|
- |
new ServerContext( zContextID, new SimpleMapServerSession() ).set(); |
77 |
|
- |
|
78 |
|
- |
DataStoreLocator.get().initializeAllTablesForTesting(); |
79 |
|
- |
} |
80 |
|
- |
} |
|
1 |
+ |
// This Source Code is in the Public Domain per: http://unlicense.org |
|
2 |
+ |
package org.litesoft.or; |
|
3 |
+ |
|
|
4 |
+ |
import org.litesoft.configuration.*; |
|
5 |
+ |
import org.litesoft.core.*; |
|
6 |
+ |
import org.litesoft.logger.*; |
|
7 |
+ |
import org.litesoft.logger.nonpublic.*; |
|
8 |
+ |
import org.litesoft.loggerconfig.*; |
|
9 |
+ |
import org.litesoft.orsup.base.*; |
|
10 |
+ |
import org.litesoft.orsup.nonpublic.*; |
|
11 |
+ |
import org.litesoft.sql.*; |
|
12 |
+ |
|
|
13 |
+ |
public class TestSupport { |
|
14 |
+ |
public static final String[] NON_JDBC_CONFIGURATION = // |
|
15 |
+ |
{ // |
|
16 |
+ |
// Block Sizing (HI/LOW) |
|
17 |
+ |
"blocksize", "100", // |
|
18 |
+ |
"objectID.blocksize", "10", // |
|
19 |
+ |
// |
|
20 |
+ |
LoggerLevel.CONFIGURATION_BASE, "Warn", // |
|
21 |
+ |
// |
|
22 |
+ |
// Add Specific Logging below: |
|
23 |
+ |
// "LoggingLevel.org.litesoft.sql.statements.JDBCexecutor", "TRACE", // |
|
24 |
+ |
// "LoggingLevel.org.litesoft.sql.statements.JDBCexecutor", "DEBUG", // |
|
25 |
+ |
// LoggerLevel.CONFIGURATION_BASE + ".org.litesoft.sql.statements.JDBCexecuteQuery", "Debug", // |
|
26 |
+ |
// LoggerLevel.CONFIGURATION_BASE + ".org.litesoft.sql.statements.JDBCexecutorNonQuery", "Debug", // |
|
27 |
+ |
}; |
|
28 |
+ |
|
|
29 |
+ |
public static final String[] HSQL_CONFIGURATION = // |
|
30 |
+ |
{ // |
|
31 |
+ |
// JDBC HSQL stuff: |
|
32 |
+ |
"databaseDriverClassName", "org.hsqldb.jdbcDriver", // |
|
33 |
+ |
"databaseURL", "jdbc:hsqldb:mem:test_pos", // |
|
34 |
+ |
"databaseUserName", "sa", // |
|
35 |
+ |
// "databaseUserPassword", "georges", // |
|
36 |
+ |
// "databaseConnectionPoolSize", "200", // |
|
37 |
+ |
// "databaseConnectionPoolDisable", "true", // |
|
38 |
+ |
}; |
|
39 |
+ |
|
|
40 |
+ |
public static void initializeConfiguration() { |
|
41 |
+ |
if ( !Configuration.isInstantiated() ) { |
|
42 |
+ |
new ServerConfiguration( new MapConfigDataAccessorFactory( NON_JDBC_CONFIGURATION, "Memory", |
|
43 |
+ |
HSQL_CONFIGURATION ) ); // force creation & self registration of Configuration |
|
44 |
+ |
LoggerFactory.init( new ConfigurationLoggerLevel() ); |
|
45 |
+ |
} |
|
46 |
+ |
} |
|
47 |
+ |
|
|
48 |
+ |
public static void beforeClass( MetaDataRegistry pRegistry ) |
|
49 |
+ |
throws Exception { |
|
50 |
+ |
try { |
|
51 |
+ |
initializeConfiguration(); |
|
52 |
+ |
DataStoreLocator.uninitialize(); |
|
53 |
+ |
DataStoreBaseSQL zMasterDataStore = new DataStoreBaseSQL( pRegistry ); |
|
54 |
+ |
DataStoreLocator.initialize( zMasterDataStore ); |
|
55 |
+ |
|
|
56 |
+ |
new DemoDataStoreManager( zMasterDataStore, pRegistry, 10 ); |
|
57 |
+ |
} |
|
58 |
+ |
catch ( Throwable e ) { |
|
59 |
+ |
System.out.println( "failed in beforeClass for SampleTest " + e ); |
|
60 |
+ |
throw new RuntimeException( e ); |
|
61 |
+ |
} |
|
62 |
+ |
} |
|
63 |
+ |
|
|
64 |
+ |
public static void afterClass() { |
|
65 |
+ |
DataStore zDataStore = DataStoreLocator.get(); |
|
66 |
+ |
if ( zDataStore != null ) { |
|
67 |
+ |
zDataStore.dropAllTables(); |
|
68 |
+ |
DataStoreLocator.uninitialize(); |
|
69 |
+ |
} |
|
70 |
+ |
} |
|
71 |
+ |
|
|
72 |
+ |
public static void beforeTest() { |
|
73 |
+ |
ServerContext.clearAllServerStores(); |
|
74 |
+ |
|
|
75 |
+ |
ContextID zContextID = new ContextID( "Test", "Test" ); |
|
76 |
+ |
new ServerContext( zContextID, new SimpleMapServerSession() ).set(); |
|
77 |
+ |
|
|
78 |
+ |
DataStoreLocator.get().initializeAllTablesForTesting(); |
|
79 |
+ |
} |
|
80 |
+ |
} |