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;
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>{
@Override
@ -37,8 +43,7 @@ public class BulletinBoardClientIntegrationTest {
@Override
public void handleFailure(Throwable t) {
thrown.add(t);
jobSemaphore.release();
genericHandleFailure(t);
}
}
@ -59,8 +64,7 @@ public class BulletinBoardClientIntegrationTest {
@Override
public void handleFailure(Throwable t) {
thrown.add(t);
jobSemaphore.release();
genericHandleFailure(t);
}
}
@ -93,8 +97,7 @@ public class BulletinBoardClientIntegrationTest {
@Override
public void handleFailure(Throwable t) {
thrown.add(t);
jobSemaphore.release();
genericHandleFailure(t);
}
}
@ -202,10 +205,7 @@ public class BulletinBoardClientIntegrationTest {
}
bulletinBoardClient.close();
for (Throwable t : thrown) {
System.err.println(t.getMessage());
}
if (thrown.size() > 0) {
assert false;
}

View File

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

View File

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

View File

@ -73,15 +73,31 @@ public class SQLiteQueryProvider implements BulletinBoardSQLServer.SQLQueryProvi
@Override
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
public DataSource getDataSource() {
// TODO: Fix this
SQLiteDataSource dataSource = new SQLiteDataSource();
dataSource.setUrl("jdbc:sqlite:" + dbName);
dataSource.setDatabaseName("meerkat"); //TODO: Make generic
return dataSource;
}

View File

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