Search in sources :

Example 1 with ConfigurationBootstrap

use of org.jboss.resteasy.plugins.server.servlet.ConfigurationBootstrap in project resteasy by resteasy.

the class ContextParameterInjectionTest method createProxy.

private Object createProxy() {
    ServletContext mockServletContext = mock(ServletContext.class);
    when(mockServletContext.getAttribute(ResteasyDeployment.class.getName())).thenReturn(null);
    ConfigurationBootstrap configBootstrap = new ListenerBootstrap(mockServletContext);
    ResteasyContext.pushContext(ResteasyDeployment.class, configBootstrap.createDeployment());
    try {
        final Class<ContainerRequestFilter> filterClass = ContainerRequestFilter.class;
        final ContainerRequestFilter coolInstance = new CoolFilter();
        ResteasyProviderFactory mockFactory = mock(ResteasyProviderFactory.class);
        when(mockFactory.getContextData(filterClass, filterClass, null, false)).thenReturn(coolInstance);
        ResteasyProviderFactory.setInstance(mockFactory);
        ContextParameterInjector cpi = new ContextParameterInjector(null, filterClass, filterClass, null, mockFactory);
        return cpi.createProxy();
    } finally {
        ResteasyContext.removeContextDataLevel();
    }
}
Also used : ResteasyDeployment(org.jboss.resteasy.spi.ResteasyDeployment) ListenerBootstrap(org.jboss.resteasy.plugins.server.servlet.ListenerBootstrap) ContainerRequestFilter(jakarta.ws.rs.container.ContainerRequestFilter) ServletContext(jakarta.servlet.ServletContext) ConfigurationBootstrap(org.jboss.resteasy.plugins.server.servlet.ConfigurationBootstrap) ResteasyProviderFactory(org.jboss.resteasy.spi.ResteasyProviderFactory)

Aggregations

ServletContext (jakarta.servlet.ServletContext)1 ContainerRequestFilter (jakarta.ws.rs.container.ContainerRequestFilter)1 ConfigurationBootstrap (org.jboss.resteasy.plugins.server.servlet.ConfigurationBootstrap)1 ListenerBootstrap (org.jboss.resteasy.plugins.server.servlet.ListenerBootstrap)1 ResteasyDeployment (org.jboss.resteasy.spi.ResteasyDeployment)1 ResteasyProviderFactory (org.jboss.resteasy.spi.ResteasyProviderFactory)1