java - Running test for database adapter using main() Method -


i have problem in system working back-end support for. need write test calls 1 of classes handeling communications our database can log out returns. think need explain setup of system before can ask question please bare me. :)

system setup

our system developed in java , deployed on weblogic server. consists of many parts not go detail on here. interesting part have class acting adapter our database. call "cmadapter" , implementations of ibm content manager specific code handle interaction our database. in class have methid called fetchact() take 1 object search parameters argument , returns result of search. in case returns 1 act. code have running on weblogic server, has ibm information integrator content installed can communicate ibm content manager installed , running on different server. system deployed on server using .ejb , few .jar files.

the problem

i have recieved case stating acts users not recieving full act expected parts of it. system displays no errors , documents present in database. trying write simple test program calls "cmadapter" predetermined set of searchcriteria may log out return of search.

my question

how can make freestading class main() method , run on server? need make call cmadapter.fetchact() method in way runs on server normal query?

my test class

     public class testhamtaakt     {             public static void main(string[] args) throws basexception         {             log log = log.getlog(testhamtaakt.class);              // cmadapter             cmadapter cmadapter = new cmadapter();             // create empty instance of our query object             sokvo sokvo = new sokvo();               // put value search in our query object             attributvo aktattribut = new attributvo();             aktattribut.setnamn(dlakonstanter.akt_kort_r_kod);              aktattribut.setvarde("090084831574");             sokvo.aktattributlista().add(aktattribut);              // search recieve answer             aktvo  aktvo = cmadapter.hamtaakt(sokvo);              // log out result             log.debug("main", "akten som hämtades: " + aktvo.tostring(), null);         }     } 

thanks reading question. appears have found answer own question. hiding collegue of mine. answer problem was, able access server deployed code, need jndi context webserver , jndi lookup class need.

i still have problems making connection problably configurations off. know how simple java class make call deployed class on server.

here code using context wls server:

     private static initialcontext getwlscontext(string url) throws namingexception     {         hashtable env = new hashtable();         env.put(context.initial_context_factory, wls_context_factory);         //env.put(context.provider_url, "t3://" + host + ":" + port);         env.put(context.provider_url, url);          return new initialcontext(env);     }  

this code geting class need.

      public static ejbobject getremote(string url, string jndiname, class homeclass, appservertyp typ) throws exception     {       object obj = getwlscontext(url).lookup(jndiname);       ejbhome home = (ejbhome) javax.rmi.portableremoteobject.narrow(obj, homeclass);        class homebase = home.getclass();       method m = homebase.getmethod("create", (class[])null);       ejbobject remote = (ejbobject) m.invoke(home, (object[])null);       return remote;    }  

i hope helps similar problem move forward. said have still code working me answer initial question on how make call deployed method external class.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -