Fixed minor H2 bug.

Fixed dbTest gradle task (now tests all 3 supported DB engines).
Bulletin-Board-Batch
Arbel Deutsch Peled 2015-12-18 14:39:40 +02:00
parent c4b0d8f23c
commit 37fdc0bb83
5 changed files with 35 additions and 17 deletions

View File

@ -27,6 +27,12 @@ public class BulletinBoardClientIntegrationTest {
Semaphore jobSemaphore; Semaphore jobSemaphore;
Vector<Throwable> thrown; Vector<Throwable> thrown;
protected void genericHandleFailure(Throwable t){
System.err.println(t.getCause() + " " + t.getMessage());
thrown.add(t);
jobSemaphore.release();
}
private class PostCallback implements ClientCallback<Object>{ private class PostCallback implements ClientCallback<Object>{
@Override @Override
@ -37,8 +43,7 @@ public class BulletinBoardClientIntegrationTest {
@Override @Override
public void handleFailure(Throwable t) { public void handleFailure(Throwable t) {
thrown.add(t); genericHandleFailure(t);
jobSemaphore.release();
} }
} }
@ -59,8 +64,7 @@ public class BulletinBoardClientIntegrationTest {
@Override @Override
public void handleFailure(Throwable t) { public void handleFailure(Throwable t) {
thrown.add(t); genericHandleFailure(t);
jobSemaphore.release();
} }
} }
@ -93,8 +97,7 @@ public class BulletinBoardClientIntegrationTest {
@Override @Override
public void handleFailure(Throwable t) { public void handleFailure(Throwable t) {
thrown.add(t); genericHandleFailure(t);
jobSemaphore.release();
} }
} }
@ -202,10 +205,7 @@ public class BulletinBoardClientIntegrationTest {
} }
bulletinBoardClient.close(); bulletinBoardClient.close();
for (Throwable t : thrown) {
System.err.println(t.getMessage());
}
if (thrown.size() > 0) { if (thrown.size() > 0) {
assert false; assert false;
} }

View File

@ -75,13 +75,15 @@ dependencies {
test { test {
exclude '**/*SQLite*Test*' exclude '**/*SQLite*Test*'
exclude '**/*H2*Test*' exclude '**/*H2*Test*'
exclude '**/*MySql*Test' exclude '**/*MySQL*Test*'
exclude '**/*IntegrationTest*' exclude '**/*IntegrationTest*'
} }
task dbTest(type: Test) { task dbTest(type: Test) {
include '**/*H2*Test*' include '**/*H2*Test*'
include '**/*MySql*Test' include '**/*MySQL*Test*'
include '**/*SQLite*Test*'
outputs.upToDateWhen { false }
} }
task integrationTest(type: Test) { task integrationTest(type: Test) {

View File

@ -74,7 +74,7 @@ public class H2QueryProvider implements BulletinBoardSQLServer.SQLQueryProvider
case MAX_MESSAGES: case MAX_MESSAGES:
return "LIMIT :Limit" + serialString; return "LIMIT :Limit" + serialString;
case MSG_ID: case MSG_ID:
return "MsgTable.MsgId = MsgId" + serialString; return "MsgTable.MsgId = :MsgId" + serialString;
case SIGNER_ID: case SIGNER_ID:
return "EXISTS (SELECT 1 FROM SignatureTable" return "EXISTS (SELECT 1 FROM SignatureTable"
+ " WHERE SignatureTable.SignerId = :SignerId" + serialString + " AND SignatureTable.EntryNum = MsgTable.EntryNum)"; + " WHERE SignatureTable.SignerId = :SignerId" + serialString + " AND SignatureTable.EntryNum = MsgTable.EntryNum)";

View File

@ -73,15 +73,31 @@ public class SQLiteQueryProvider implements BulletinBoardSQLServer.SQLQueryProvi
@Override @Override
public String getConditionParamTypeName(FilterType filterType) throws IllegalArgumentException { public String getConditionParamTypeName(FilterType filterType) throws IllegalArgumentException {
return null; //TODO: write this.
switch(filterType) {
case EXACT_ENTRY: // Go through
case MAX_ENTRY: // Go through
case MAX_MESSAGES:
return "INTEGER";
case MSG_ID: // Go through
case SIGNER_ID:
return "BLOB";
case TAG:
return "VARCHAR";
default:
throw new IllegalArgumentException("Cannot serve a filter of type " + filterType);
}
} }
@Override @Override
public DataSource getDataSource() { public DataSource getDataSource() {
// TODO: Fix this
SQLiteDataSource dataSource = new SQLiteDataSource(); SQLiteDataSource dataSource = new SQLiteDataSource();
dataSource.setUrl("jdbc:sqlite:" + dbName); dataSource.setUrl("jdbc:sqlite:" + dbName);
dataSource.setDatabaseName("meerkat"); //TODO: Make generic
return dataSource; return dataSource;
} }

View File

@ -31,7 +31,7 @@
<param-value>mypass</param-value></context-param> <param-value>mypass</param-value></context-param>
<context-param> <context-param>
<param-name>dbType</param-name> <param-name>dbType</param-name>
<param-value>SQLite</param-value></context-param> <param-value>H2</param-value></context-param>
<listener> <listener>
<listener-class>meerkat.bulletinboard.webapp.BulletinBoardWebApp</listener-class> <listener-class>meerkat.bulletinboard.webapp.BulletinBoardWebApp</listener-class>
</listener> </listener>