【问题标题】:Unit Testing Spring Security With Weblogic Container使用 Weblogic 容器对 Spring Security 进行单元测试
【发布时间】:2012-02-22 16:28:51
【问题描述】:

我正在尝试使用 weblogic 10.3.5 容器对 Spring Security 进行单元测试。已经为我提供了一个 Eclipse 和 Weblogic 的环境,这两个我都不太熟悉。

启动时出现异常:

java.lang.NoClassDefFoundError: javax/servlet/Filter
    at java.lang.ClassLoader.defineClass1(Native Method)
    blahblahblah

因此,此单元测试失败:

    @Test
    public void testGetByIdViaAccessRoles() {
        Person result;

      // Test the results with a ROLE_ADMIN user. This SHOULD work.
    SecurityContextHolder.getContext().setAuthentication(admin);
    result = personRepository.getById(1L);
    assertNotNull(result);

    // test the results with a ROLE_USER. Should also be good...
    SecurityContextHolder.getContext().setAuthentication(user);
    result = personRepository.getById(1L);
    assertNotNull(result);

    // test the results with a nonexistent user. Should go kablooie.
    SecurityContextHolder.getContext().setAuthentication(nonuser);
    try {
        result = personRepository.getById(1L);
        fail("Should be impossible to get this with a nonexistent user.");
    } catch (AccessDeniedException ex) {

    }
}

所以,我猜我没有从 weblogic 中获取 servlet.jar。但由于我是一个相对较新的 eclipse 用户(长期使用 IntelliJ),我不确定我是否正确设置了 weblogic。

在我的项目方面,我检查了 Oracle WebLogic Web App Extensions,但没有配置其他 weblogic。动态 Web 模块也被选中。

任何人都可以为相对新手提供帮助吗?

杰森

【问题讨论】:

    标签: spring-security weblogic


    【解决方案1】:

    无视。在某个地方,我找到了目标运行时的另一种选择。一旦我设置它,它就起作用了。

    【讨论】:

      猜你喜欢
      • 2010-09-26
      • 2017-10-21
      • 2014-04-27
      • 2016-06-05
      • 1970-01-01
      • 1970-01-01
      • 2019-07-07
      • 2014-02-08
      • 1970-01-01
      相关资源
      最近更新 更多