0 Replies Latest reply on Apr 6, 2005 9:13 AM by Mukti furtado

    junit.awtui.TestRunner- classnotfound error

    Mukti furtado Newbie

      Hello,

      I have written a junit testCase to test EJB. I am calling the testcase from a jsp. My problem is i get the awt window but it says class not found.can someone help me with this problem. i have included the junit.jar in my classpath. below is the code for my jsp and testcase.

      jsp
      <%@page import="java.rmi.*" %>
      <%@page import="java.util.*" %>
      <%@page import="javax.naming.*" %>
      <%@page import="javax.rmi.*" %>
      <%@page import="teste.*" %>

      Test

      <%
      try {
      EndUserTests eu = new EndUserTests("testInsert");
      eu.test1();
      } catch (Exception ex) {
      ex.printStackTrace(System.out);
      }
      %>



      junit TestCase
      package teste;

      import javax.ejb.*;
      import javax.naming.*;
      import javax.rmi.*;
      import java.rmi.*;
      import java.util.*;

      import junit.framework.*;

      public class EndUserTests extends TestCase{

      private EnduserHome home;
      public static TestSuite suite;
      public EndUserTests(){
      }
      public EndUserTests(String testname){
      super(testname);
      }

      public void setUp() throws Exception{

      Context ic = new InitialContext();
      Object object = ic.lookup("ejb/Example/Enduser");
      home = (EnduserHome)PortableRemoteObject.narrow(object, EnduserHome.class);

      }
      //public static void main(String[] args){
      //junit.textui.TestRunner.run(EndUserTests.class);
      //}
      public void test1(){
      junit.awtui.TestRunner.run(EndUserTests.class);
      }

      public static TestSuite suite(){
      suite = new TestSuite();
      suite.addTest(new EndUserTests("testInsert"));
      return suite;
      }
      public void testInsert() throws Exception{

      Enduser eu = null;
      try{

      eu = home.create(new Integer(1),"muktitest","thomas","Frank","Otto","sunnyvale","california",new Integer(21476890),"thomas@hotmail.com",new Integer(76676654),new Integer(21476890),new Date(),new Integer(76),"Y");
      }
      catch(Exception e)
      {
      e.printStackTrace();

      }

      Assert.assertEquals(eu.getUserName(),"muktitest");
      }
      }