خرید بک لینک

Vote count: 0

In my Jersey 2 based rest application, I have added spring security filter chain to check authentication. Everything works well except during unit-test if I try to add that security chain I get 500 error (and the code pointer never goes to service resource methods). According to this ticket, adding filter chain in JerseyTest should be fixed by now.

But I am yet to find a way to do it properly. My JerseySpringTest class look like this:

@RunWith(SpringJUnit4ClassRuer.class)
@ContextConfiguration(locations = {"classpath:META-INF/applicationContext-test.xml", "classpath:META-INF/security-context.xml"})
@ActiveProfiles("unit-test")
@WebAppConfiguration
public abstract class JerseySpringTest {

private JerseyTest _jerseyTest;

public final WebTarget target(final String path) {
    retu _jerseyTest.target(path);
}

@Before
public void setupJerseyTest() throws Exception {
    _jerseyTest.setUp();
}

@After
public void tearDownJerseyTest() throws Exception {
    _jerseyTest.tearDown();
}

@Autowired
public void setApplicationContext(final ApplicationContext context) {
    _jerseyTest = new JerseyTest() {
        @Override
        protected Application configure() {
            ResourceConfig application = JerseySpringTest.this.configure();
            application.register(CustormDelegatingFilterProxy.class);
            application.property("springSecurityFilterChain", "/services/*");
            application.property("contextConfig", context);
            retu application;
        }

    };
}

protected abstract ResourceConfig configure();
}

Any help will be appreciated.

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 28 ارديبهشت 1395 ساعت: 16:43

صفحه بندی