package com.ff.ldap;
import junit.framework.TestCase;
import junit.framework.TestSuite;
public class LdapUtilTests extends TestCase {
public LdapUtilTests(String name) {
super(name);
}
public void testTrue() {
int i = LdapUtil.authenticate("info", "info");
assertTrue(i == 0);
}
public void testUserNameError() {
int i = LdapUtil.authenticate("wangsifa", "wangsf");
assertTrue(i == 5);
}
public void testPasswordError() {
int i = LdapUtil.authenticate("wangsifa", "wangsf");
assertTrue(i == 10);
}
public void testInfo() {
int i = LdapUtil.authenticate("info", "info");
if (i == 0) {
System.out.println("0正确访问");
} else if (i == 5) {
System.out.println("5用户不存在");
} else {
System.out.println("10:密码不正确");
}
}
public static TestSuite suite() {
TestSuite suite = new TestSuite();
suite.addTest(new LdapUtilTests("testInfo"));
return suite;
}
}
最后一个方法可实现只运行本测试案例中的部分.