Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.liferay.com/repos/public/portal/trunk@42096 05bdf26c-840f-0410-9ced-eb539d925f36
  • Loading branch information
brianchandotcom committed Dec 8, 2009
1 parent 77708b1 commit 40afa57
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 13 deletions.
18 changes: 18 additions & 0 deletions benchmarks/benchmarks.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@
#
sample.sql.output.dir=.

#
# Specify the database type of the generated SQL files.
#
#sample.sql.db.type=db2
#sample.sql.db.type=derby
#sample.sql.db.type=firebird
#sample.sql.db.type=hypersonic
#sample.sql.db.type=informix
#sample.sql.db.type=ingres
#sample.sql.db.type=interbase
#sample.sql.db.type=jdatastore
sample.sql.db.type=mysql
#sample.sql.db.type=oracle
#sample.sql.db.type=postgresql
#sample.sql.db.type=sap
#sample.sql.db.type=sqlserver
#sample.sql.db.type=sybase

#
# Specify the number of comments to generate per blogs entry.
#
Expand Down
1 change: 1 addition & 0 deletions benchmarks/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
>
<jvmarg value="-Dexternal-properties=com/liferay/portal/tools/dependencies/portal-tools.properties" />
<jvmarg value="-Dsample.sql.output.dir=${sample.sql.output.dir}" />
<jvmarg value="-Dsample.sql.db.type=${sample.sql.db.type}" />
<jvmarg value="-Dsample.sql.blogs.entry.comment.count=${sample.sql.blogs.entry.comment.count}" />
<jvmarg value="-Dsample.sql.blogs.entry.count=${sample.sql.blogs.entry.count}" />
<jvmarg value="-Dsample.sql.group.count=${sample.sql.group.count}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public static void main(String[] args) {
InitUtil.initWithSpring();

String outputDir = System.getProperty("sample.sql.output.dir");
String dbType = System.getProperty("sample.sql.db.type");
int maxBlogsEntryCommentCount = GetterUtil.getInteger(
System.getProperty("sample.sql.blogs.entry.comment.count"));
int maxBlogsEntryCount = GetterUtil.getInteger(
Expand All @@ -97,22 +98,24 @@ public static void main(String[] args) {
System.getProperty("sample.sql.security.enabled"));

new SampleSQLBuilder(
outputDir, maxBlogsEntryCommentCount, maxBlogsEntryCount,
outputDir, dbType, maxBlogsEntryCommentCount, maxBlogsEntryCount,
maxGroupCount, maxMBCategoryCount, maxMBMessageCount,
maxMBThreadCount, maxUserCount, maxUserToGroupCount,
maxWikiNodeCount, maxWikiPageCommentCount, maxWikiPageCount,
securityEnabled);
}

public SampleSQLBuilder(
String outputDir, int maxBlogsEntryCommentCount, int maxBlogsEntryCount,
int maxGroupCount, int maxMBCategoryCount, int maxMBMessageCount,
int maxMBThreadCount, int maxUserCount, int maxUserToGroupCount,
int maxWikiNodeCount, int maxWikiPageCommentCount, int maxWikiPageCount,
String outputDir, String dbType, int maxBlogsEntryCommentCount,
int maxBlogsEntryCount, int maxGroupCount, int maxMBCategoryCount,
int maxMBMessageCount, int maxMBThreadCount, int maxUserCount,
int maxUserToGroupCount, int maxWikiNodeCount,
int maxWikiPageCommentCount, int maxWikiPageCount,
boolean securityEnabled) {

try {
_outputDir = outputDir;
_dbType = dbType;
_maxBlogsEntryCommentCount = maxBlogsEntryCommentCount;
_maxBlogsEntryCount = maxBlogsEntryCount;
_maxGroupCount = maxGroupCount;
Expand Down Expand Up @@ -155,11 +158,12 @@ public SampleSQLBuilder(

_writerGeneric.flush();

// MySQL
// Specific

_writerMySQL = new FileWriter(_outputDir + "/sample-mysql.sql");
_writerSpecific = new FileWriter(
_outputDir + "/sample-" + dbType + ".sql");

DB mysqlDB = DBFactoryUtil.getDB(DB.TYPE_MYSQL);
DB specificDB = DBFactoryUtil.getDB(_dbType);

boolean previousBlankLine = false;

Expand All @@ -169,14 +173,14 @@ public SampleSQLBuilder(
String s = null;

while ((s = br.readLine()) != null) {
s = mysqlDB.buildSQL(s).trim();
s = specificDB.buildSQL(s).trim();

_writerMySQL.write(s);
_writerSpecific.write(s);

if (previousBlankLine && Validator.isNull(s)) {
}
else {
_writerMySQL.write(StringPool.NEW_LINE);
_writerSpecific.write(StringPool.NEW_LINE);
}

if (Validator.isNull(s)) {
Expand All @@ -186,7 +190,7 @@ public SampleSQLBuilder(

br.close();

_writerMySQL.flush();
_writerSpecific.flush();
}
catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -399,6 +403,7 @@ protected void put(Map<String, Object> context, String key, Object value) {

private SimpleCounter _counter;
private DataFactory _dataFactory;
private String _dbType;
private int _maxBlogsEntryCommentCount;
private int _maxBlogsEntryCount;
private int _maxGroupCount;
Expand Down Expand Up @@ -431,6 +436,6 @@ protected void put(Map<String, Object> context, String key, Object value) {
private String _tplWikiPage = _TPL_ROOT + "wiki_page.ftl";
private SimpleCounter _userScreenNameIncrementer;
private Writer _writerGeneric;
private Writer _writerMySQL;
private Writer _writerSpecific;

}

0 comments on commit 40afa57

Please sign in to comment.