• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

junit.awtui.TestRunner- classnotfound error

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.*" %>
<html>
<head><title>Test</title></head>
<body>
<%
try {
EndUserTests eu = new EndUserTests("testInsert");
eu.test1();
} catch (Exception ex) {
ex.printStackTrace(System.out);
}
%>
</body>
</html>

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.swingui.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");
}
}
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you describe your ClassNotFoundError in a bit more detail?

Also, you really should look into JUnitEE or Cactus for running unit tests inside a server. That JSP thing you're doing is not too user friendly, you know...
 
Attractive, successful people love this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic