单元测试抛出默认管理员用户名不可用错误

问题描述 投票:0回答:1

我正在使用alfresco6。在我要测试的方法之一中,具有以下代码:

if(AuthenticationUtil.getFullyAuthenticatedUser().equals("xyz"))
{
        return;
}

我要在进行此单元测试时强制此条件为假。

在单元测试中,我有一个@Before,它具有以下内容:

AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();

在实际测试中,我没有任何与AuthenticationUtil相关的代码。

我收到以下错误:

java.lang.IllegalStateException: AuthenticationUtil not yet initialised; default admin username not available
at org.alfresco.repo.security.authentication.AuthenticationUtil.getAdminUserName(AuthenticationUtil.java:450)

我想念什么?

java mockito alfresco
1个回答
2
投票

检查AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();方法。

它最有可能运行AuthenticationUtil.getAdminUserName()方法,该方法位于AuthenticationUtil类的第450行,并且似乎需要用户名admin。

© www.soinside.com 2019 - 2024. All rights reserved.