public interface UserHome extends javax.ejb.EJBLocalHome {
public User create(String name, String password) throws CreateException;
public Collection findAll() throws FinderException;
public User findByPrimaryKey(String name) throws FinderException;
}
User.java
package usersystem;
import javax.ejb.*;
import java.util.*;
public interface User extends javax.ejb.EJBLocalObject {
public String getName();
public void setPassword(String password);
public String getPassword();
public void setUserInfo(UserInfo userInfo);
public UserInfo getUserInfo();
public void setName(String name);
}
UserInfoHome.java
package usersystem;
import javax.ejb.*;
import java.util.*;
public interface UserInfoHome extends javax.ejb.EJBLocalHome {
public UserInfo create(String name, String email, String address, String tel) throws
CreateException;
public UserInfo findByPrimaryKey(String name) throws FinderException;
}
public interface UserManagerLocal extends javax.ejb.EJBLocalObject {
public void addUser(String name, String password, String email, String address, String tel);
public Collection findAll() ;
public void delAll();
public void delByName(String name);
public User findByName(String name) ;
}
public class UserManagerBean implements SessionBean {
SessionContext sessionContext;
public void ejbCreate() throws CreateException {
/**@todo Complete this method*/
}
public void ejbRemove() {
/**@todo Complete this method*/
}
public void ejbActivate() {
/**@todo Complete this method*/
}
public void ejbPassivate() {
/**@todo Complete this method*/
}
public void setSessionContext(SessionContext sessionContext) {
this.sessionContext = sessionContext;
}
public class ManaServletTest extends ServletTestCase{
ManaServlet servlet=new ManaServlet();
public ManaServletTest(String theName) {
super(theName);
}
public void testDel() throws javax.ejb.EJBException {
servlet.delUser("nameValue8") ;
}
public void testDelAll() throws javax.ejb.EJBException {
servlet.delAll() ;
}
public static void main(String[] theArgs)
{
junit.textui.TestRunner.main(new String[]{
ManaServletTest.class.getName()});
}
public static Test suite()
{
return new TestSuite(ManaServletTest.class);
}
}
public class ManaServletTest extends ServletTestCase 我们要测试的是一个servlet,所以我们继承ServletTestCase,如果你测试jsp的话,就继承JspTestCase.
public ManaServletTest(String theName) {
super(theName);
}