java - NullPointerException, integration test ejb -


i have web services many method, before "test it" manually soap, want junit , other framework interact database , use @ejb annotation. first example found, use dbunit , connected database , put row table(and works). when try reuse connection, , try directly invoke @stateless method have many error such nullpointer exception on ejb or on entity manager, tried complet different logic , use mockito, this:

public class reportbeantest {      //this stateless class     private reportfc reportbean = new reportfc();      @before     public void injectmockentitymanager() throws exception {         entitymanager entitymanager = mock(entitymanager.class);         reportbean.emreport = entitymanager;         datefc datef= mock(datefc.class);         reportbean.datef =datef;         querysfc queryf= mock(querysfc .class);         reportbean.queryf =queryf;         reportbean.getreport("myreporta", new date(), new date());     } } 

and here reportfc.java :

    @stateless     public class reportfc {     @persistencecontext(unitname="mydb")         public         entitymanager emreport;         @ejb         public         datefc datef;          @ejb         public         querysfc queryf;          public list<mylist> getreport(string myreport,                 date from_date,                 date to_date                 ) throws wsexception {             try{                 list<wsmap_v3> resultlist = new linkedlist<wsmap_v3>();                  date start= dataf.parserdateformat(from_date,0,"notime");                 date end= dataf.parserdateformat(to_date,0,"notime");                 datef.verifytimeinterval(start,end);                 query qc=queryf.querygetreportbetweendate(start, end, myreporta); ...///     } 

i have see every variable use external ejb null, in case : date start, date end, query qc on.... doing wrong? there other way test function use ejb or entitymanager? using maven if there other framework use have no problem import it. other thing: bean of db in jar import maven dependecy


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -