Hi,
Can you please help???
I'm trying a simple Junit tet to read a db table but I get a java null pointer exception:
java.lang.NullPointerException.
at com.test.mainsys.sysmodel.dao.FxRateDAO.findFxRate History(FxRateDAO.java:109)
at com.test.eq.sysmodel.dao.FxRateDAOTest.testFindFxR ateByHistory(FxRateDAOTest.java:143)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:41)
at java.lang.reflect.Method.invoke(Method.java:386)
at junit.framework.TestCase.runTest(TestCase.java:154 )
at junit.framework.TestCase.runBare(TestCase.java:127 )
at junit.framework.TestResult$1.protect(TestResult.ja va:106)
at junit.framework.TestResult.runProtected(TestResult .java:124)
at junit.framework.TestResult.run(TestResult.java:109 )
at junit.framework.TestCase.run(TestCase.java:118)
The DAO code is
public final List findFxRateHistory(
final String fromCcy,
final String toCcy
)
throws ObjectRetrievalDAOException, FinderDAOException {
System.out.println(fromCcy);
System.out.println(toCcy);
Object[] objectArray = { fromCcy,toCcy };
Type[] typeArray = { Hibernate.STRING,Hibernate.STRING };
System.out.println("before list");
return.getHibernateTemplate().find("from fx_rate where
ccy1 = ? and ccy=?",
objectArray,typeArray);
//NOTE the table name in lowercase.
}
In the Junit test:
dao = (FxRateDAO) getAppCtx().getBean("fx_rate");
List readFxHistory = dao.findFxRateHistory(fromCc, toCc);


Reply With Quote