电子邮件ID验证失败了

时间:2013-06-04 07:00:00

标签: java eclipse email ant junit

我编写了一个JUnit测试用例,用于验证提供给它的电子邮件ID,此测试用例将电子邮件ID传递给验证框架,该框架返回true或false,验证框架类使用mail.jar验证电子邮件ID。

现在,当我使用JUnit验证firstlast@example.com emailID时,它运行成功。 我还编写了一个使用命令行运行这个tescases的ant脚本,当我运行上面的emailID时,ant脚本也运行成功。

但是当我使用电子邮件ID运行相同的测试用例\"firstlast\"@example.com时(此电子邮件ID在JUnit类的函数中指定,验证器类接收的实际值为"firstlast@example.com"双引号在此处转义) testcase在eclipse中运行成功,但是使用ant脚本测试用例失败。

我无法找到为什么ant脚本无法执行测试用例,而eclipse运行成功。

电子邮件ID验证码

public static boolean isValidEmailViaInternetAddress(String szEmailId)
{
    boolean bValid= true;

    try
    {
       InternetAddress oInternetAddress = new InternetAddress(szEmailId);
       oInternetAddress.validate();
    }
    // validate will throw the exception if emailid is not in proper format
    catch(AddressException e)
    {
       log.error("Could not verify emailID :" + szEmailId + ": Error is : " + e);
       bValid=false;
    }
    return bValid;
}`

0 个答案:

没有答案
相关问题