• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

junit.awtui.TestRunner- classnotfound error

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • 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
  • 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...
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic