Hey y'all,

I'm working on an EJBTestCase which extends TestCase so that unit testing
can be performed for EJBs too. EJBTestCase provides some utility methods to
allow for loading the EJB to be tested. I'd like some feedback about what
everyone thinks. Please forgive any newbie concepts or questions I have...

I've a constructor...

 public EJBTestCase(String theName){
        super(theName);
  try{
   // Load properties from j2ee.properties located somewhere in the
classpath
   getProperties();
  }
  catch(IOException ioe){
   System.out.println("j2ee.properties may not be in your classpath.");
   System.out.println(ioe.getMessage());
  }
  }

Currently, getProperties() allows for absolute path of j2ee.properties but
I'll modify it to load j2ee.properties from anywhere in the class path.

 public void getProperties() throws IOException, FileNotFoundException
 {
  // create properties
  j2eeProps = new Properties();

  // load properties
  FileInputStream in = new FileInputStream("c:\\jdk1.3\\j2ee.properties");
  j2eeProps.load(in);
  in.close();
 }

The other methods of interest are
 /**
  * @param jndiName The JNDI name to lookup.
  * Utility method which performs a JNDI Context Lookup given the name of
the context
  */
 protected void doLookUp(String jndiName) throws NamingException
 {
  Object objRef= jndiContext.lookup(jndiName);
  System.out.println("Lookup successful");
 }

 /**
  *
  * @param ejbhomeclass The class name of the EJB Home interface
  * @return EJBHome The EJB Home Interface
  * Utility method which returns the EJBHome object
  */
 protected EJBHome getHome(Class ejbhomeclass)
 {
  return (EJBHome)PortableRemoteObject.narrow(objRef, ejbhomeclass);
 }

Comments, feedback please?


Reply via email to