use of jakarta.servlet.ServletConfig in project atmosphere by Atmosphere.
the class AtmosphereFrameworkTest method autodetectBroadcaster.
@Test(dataProvider = "autodetectBroadcaster")
public void autodetectBroadcaster(String autodetectBroadcasterConfig, boolean expectedAutodetect) {
ServletConfig servletConfig = mock(ServletConfig.class);
when(servletConfig.getInitParameter(ApplicationConfig.AUTODETECT_BROADCASTER)).thenReturn(autodetectBroadcasterConfig);
AtmosphereFramework framework = new AtmosphereFramework();
framework.servletConfig = servletConfig;
boolean actualAutodetect = framework.autodetectBroadcaster();
assertEquals(actualAutodetect, expectedAutodetect);
}
use of jakarta.servlet.ServletConfig in project atmosphere by Atmosphere.
the class AtmosphereFrameworkTest method testAtmosphereFrameworkListener.
@Test
public void testAtmosphereFrameworkListener() throws ServletException {
AtmosphereServlet s = new MyAtmosphereServlet();
final AtomicInteger count = new AtomicInteger();
s.framework().frameworkListener(new AtmosphereFrameworkListener() {
@Override
public void onPreInit(AtmosphereFramework f) {
count.incrementAndGet();
}
@Override
public void onPostInit(AtmosphereFramework f) {
count.incrementAndGet();
}
@Override
public void onPreDestroy(AtmosphereFramework f) {
count.incrementAndGet();
}
@Override
public void onPostDestroy(AtmosphereFramework f) {
count.incrementAndGet();
}
});
s.init(new ServletConfig() {
@Override
public String getServletName() {
return "void";
}
@Override
public ServletContext getServletContext() {
return mock(ServletContext.class);
}
@Override
public String getInitParameter(String name) {
if (ApplicationConfig.WEBSOCKET_SUPPRESS_JSR356.equals(name)) {
return "true";
}
return null;
}
@Override
public Enumeration<String> getInitParameterNames() {
return null;
}
});
s.destroy();
assertEquals(count.get(), 4);
}
use of jakarta.servlet.ServletConfig in project atmosphere by Atmosphere.
the class AtmosphereInterceptorTest method create.
@BeforeMethod
public void create() throws Throwable {
framework = new AtmosphereFramework();
framework.setAsyncSupport(mock(AsyncSupport.class));
framework.init(new ServletConfig() {
@Override
public String getServletName() {
return "void";
}
@Override
public ServletContext getServletContext() {
return mock(ServletContext.class);
}
@Override
public String getInitParameter(String name) {
return null;
}
@Override
public Enumeration<String> getInitParameterNames() {
return null;
}
});
config = framework.getAtmosphereConfig();
processor = new AsynchronousProcessor(config) {
@Override
public Action service(AtmosphereRequest req, AtmosphereResponse res) throws IOException, ServletException {
return action(req, res);
}
};
}
use of jakarta.servlet.ServletConfig in project atmosphere by Atmosphere.
the class AtmosphereRequestTest method create.
@BeforeMethod
public void create() throws Throwable {
framework = new AtmosphereFramework();
framework.setAsyncSupport(new BlockingIOCometSupport(framework.getAtmosphereConfig()));
framework.init(new ServletConfig() {
@Override
public String getServletName() {
return "void";
}
@Override
public ServletContext getServletContext() {
return mock(ServletContext.class);
}
@Override
public String getInitParameter(String name) {
return null;
}
@Override
public Enumeration<String> getInitParameterNames() {
return null;
}
});
}
use of jakarta.servlet.ServletConfig in project atmosphere by Atmosphere.
the class AtmosphereResourceListenerTest method create.
@BeforeMethod
public void create() throws Throwable {
framework = new AtmosphereFramework();
framework.setAsyncSupport(new BlockingIOCometSupport(framework.getAtmosphereConfig()));
framework.init(new ServletConfig() {
@Override
public String getServletName() {
return "void";
}
@Override
public ServletContext getServletContext() {
return mock(ServletContext.class);
}
@Override
public String getInitParameter(String name) {
return null;
}
@Override
public Enumeration<String> getInitParameterNames() {
return null;
}
});
}
Aggregations