use of jakarta.servlet.http.HttpServlet in project atmosphere by Atmosphere.
the class MeteorTest method testMeteor.
@Test
public void testMeteor() throws IOException, ServletException {
final AtomicReference<Meteor> meteor = new AtomicReference<Meteor>();
final Servlet s = new HttpServlet() {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
meteor.set(Meteor.lookup(req));
}
};
framework.addAtmosphereHandler("/a", new ReflectorServletProcessor(s));
AtmosphereRequest request = new AtmosphereRequestImpl.Builder().pathInfo("/a").build();
framework.interceptor(new AtmosphereInterceptorAdapter() {
@Override
public Action inspect(AtmosphereResource r) {
Meteor m = Meteor.build(r.getRequest());
return Action.CONTINUE;
}
});
framework.doCometSupport(request, AtmosphereResponseImpl.newInstance());
assertNotNull(meteor.get());
}
use of jakarta.servlet.http.HttpServlet in project atmosphere by Atmosphere.
the class MeteorTest method testMeteorNull.
@Test
public void testMeteorNull() throws IOException, ServletException {
final AtomicReference<Meteor> meteor = new AtomicReference<Meteor>();
final Servlet s = new HttpServlet() {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
meteor.set(Meteor.lookup(req));
}
};
framework.addAtmosphereHandler("/a", new ReflectorServletProcessor(s));
AtmosphereRequest request = new AtmosphereRequestImpl.Builder().pathInfo("/a").build();
framework.interceptor(new AtmosphereInterceptorAdapter() {
@Override
public Action inspect(AtmosphereResource r) {
return Action.CONTINUE;
}
});
framework.doCometSupport(request, AtmosphereResponseImpl.newInstance());
assertNull(meteor.get());
}
use of jakarta.servlet.http.HttpServlet in project tomcat by apache.
the class TestMimeHeadersIntegration method setupHeadersTest.
private void setupHeadersTest(Tomcat tomcat) {
Context ctx = tomcat.addContext("", getTemporaryDirectory().getAbsolutePath());
Tomcat.addServlet(ctx, "servlet", new HttpServlet() {
private static final long serialVersionUID = 1L;
@Override
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
res.setContentType("text/plain; charset=ISO-8859-1");
res.getWriter().write("OK");
}
});
ctx.addServletMappingDecoded("/", "servlet");
alv = new HeaderCountLogValve();
tomcat.getHost().getPipeline().addValve(alv);
}
use of jakarta.servlet.http.HttpServlet in project tomcat by apache.
the class TestExpiresFilter method testUseContentTypeExpiresConfiguration.
@Test
public void testUseContentTypeExpiresConfiguration() throws Exception {
HttpServlet servlet = new HttpServlet() {
private static final long serialVersionUID = 1L;
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/xml; charset=utf-8");
response.getWriter().print("Hello world");
}
};
validate(servlet, Integer.valueOf(3 * 60));
}
use of jakarta.servlet.http.HttpServlet in project tomcat by apache.
the class TestExpiresFilter method testUseContentTypeWithoutCharsetExpiresConfiguration.
@Test
public void testUseContentTypeWithoutCharsetExpiresConfiguration() throws Exception {
HttpServlet servlet = new HttpServlet() {
private static final long serialVersionUID = 1L;
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/xml; charset=iso-8859-1");
response.getWriter().print("Hello world");
}
};
validate(servlet, Integer.valueOf(5 * 60));
}
Aggregations