QueryTest : minor refactoring - use assertExceptionThrowed method

This commit is contained in:
teo_sarca 2009-01-29 17:37:52 +00:00
parent 0ff2ad9ef6
commit fafda130ee
1 changed files with 24 additions and 37 deletions

View File

@ -23,17 +23,12 @@ public class QueryTest extends AdempiereTestCase
{ {
public void testQuery_NoTable() throws Exception public void testQuery_NoTable() throws Exception
{ {
boolean exThrowed = false; assertExceptionThrowed("", IllegalArgumentException.class, new Runnable(){
try public void run()
{ {
new Query(getCtx(), "NO_TABLE_DEFINED", null, getTrxName()); new Query(getCtx(), "NO_TABLE_DEFINED", null, getTrxName());
} }
catch (RuntimeException e) });
{
exThrowed = true;
//e.printStackTrace();
}
assertTrue("No Error Was Throwed", exThrowed);
} }
public void testList() throws Exception public void testList() throws Exception
@ -120,19 +115,15 @@ public class QueryTest extends AdempiereTestCase
public void testCount_BadSQL() throws Exception public void testCount_BadSQL() throws Exception
{ {
boolean exThrowed = false; assertExceptionThrowed(null, DBException.class, new Runnable(){
try public void run()
{ {
new Query(getCtx(), "AD_Table", "TableName IN (?,?) AND BAD_SQL", getTrxName()) new Query(getCtx(), "AD_Table", "TableName IN (?,?) AND BAD_SQL", getTrxName())
.setParameters(new Object[]{"C_Invoice", "M_InOut"}) .setParameters(new Object[]{"C_Invoice", "M_InOut"})
.setOrderBy("TableName") .setOrderBy("TableName")
.count(); .count();
} }
catch (DBException e) });
{
exThrowed = true;
}
assertTrue("No Error Was Throwed", exThrowed);
} }
public void testCount_NoValues() throws Exception public void testCount_NoValues() throws Exception
@ -157,19 +148,15 @@ public class QueryTest extends AdempiereTestCase
.firstOnly(); .firstOnly();
assertEquals("Invalid table ID", 318, t.get_ID()); assertEquals("Invalid table ID", 318, t.get_ID());
// //
Exception ex = null; assertExceptionThrowed(null, DBException.class, new Runnable(){
try public void run()
{ {
t = new Query(getCtx(), "AD_Table", "TableName IN (?,?)", getTrxName()) new Query(getCtx(), "AD_Table", "TableName IN (?,?)", getTrxName())
.setParameters(new Object[]{"C_Invoice", "M_InOut"}) .setParameters(new Object[]{"C_Invoice", "M_InOut"})
.setOrderBy("TableName") .setOrderBy("TableName")
.firstOnly(); .firstOnly();
} }
catch (DBException e) });
{
ex = e;
}
assertNotNull("Exception should be throwed", ex);
} }
public void testSetClient_ID() throws Exception public void testSetClient_ID() throws Exception