Skip to content

Commit

Permalink
Fix deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
slandelle committed Sep 25, 2017
1 parent d3a2861 commit 3975e72
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
Expand Up @@ -17,7 +17,6 @@

import static org.asynchttpclient.Dsl.asyncHttpClient;
import static org.testng.Assert.*;
import io.netty.handler.codec.http.HttpHeaders;

import java.io.IOException;
import java.io.PrintWriter;
Expand All @@ -29,17 +28,18 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

import javax.servlet.AsyncContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.eclipse.jetty.continuation.Continuation;
import org.eclipse.jetty.continuation.ContinuationSupport;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;

import io.netty.handler.codec.http.HttpHeaders;

/**
* Tests default asynchronous life cycle.
*
Expand All @@ -61,8 +61,7 @@ public AbstractHandler configureHandler() throws Exception {
public void handle(String s, Request request, HttpServletRequest req, final HttpServletResponse resp) throws IOException, ServletException {
resp.setContentType("text/plain;charset=utf-8");
resp.setStatus(200);
final Continuation continuation = ContinuationSupport.getContinuation(req);
continuation.suspend();
final AsyncContext asyncContext = request.startAsync();
final PrintWriter writer = resp.getWriter();
executorService.submit(new Runnable() {
public void run() {
Expand All @@ -86,7 +85,7 @@ public void run() {
logger.info("Delivering part2.");
writer.write("part2");
writer.flush();
continuation.complete();
asyncContext.complete();
}
});
request.setHandled(true);
Expand Down
Expand Up @@ -25,12 +25,11 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import javax.servlet.AsyncContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.eclipse.jetty.continuation.Continuation;
import org.eclipse.jetty.continuation.ContinuationSupport;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.testng.annotations.Test;
Expand Down Expand Up @@ -60,8 +59,7 @@ public AbstractHandler configureHandler() throws Exception {
private class SlowHandler extends AbstractHandler {
public void handle(String target, Request baseRequest, HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException {
response.setStatus(HttpServletResponse.SC_OK);
final Continuation continuation = ContinuationSupport.getContinuation(request);
continuation.suspend();
final AsyncContext asyncContext = request.startAsync();
new Thread(new Runnable() {
public void run() {
try {
Expand All @@ -81,7 +79,7 @@ public void run() {
Thread.sleep(3000);
response.getOutputStream().print(MSG);
response.getOutputStream().flush();
continuation.complete();
asyncContext.complete();
} catch (InterruptedException e) {
logger.error(e.getMessage(), e);
} catch (IOException e) {
Expand Down
Expand Up @@ -24,6 +24,7 @@
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;

import javax.servlet.AsyncContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Expand All @@ -32,8 +33,6 @@
import org.asynchttpclient.AsyncCompletionHandler;
import org.asynchttpclient.AsyncHttpClient;
import org.asynchttpclient.Response;
import org.eclipse.jetty.continuation.Continuation;
import org.eclipse.jetty.continuation.ContinuationSupport;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.testng.annotations.Test;
Expand All @@ -51,15 +50,14 @@ private class SlowHandler extends AbstractHandler {
public void handle(String target, Request baseRequest, HttpServletRequest request, final HttpServletResponse response)
throws IOException, ServletException {
response.setStatus(HttpServletResponse.SC_OK);
final Continuation continuation = ContinuationSupport.getContinuation(request);
continuation.suspend();
final AsyncContext asyncContext = request.startAsync();
new Thread(new Runnable() {
public void run() {
try {
Thread.sleep(SLEEPTIME_MS);
response.getOutputStream().print(MSG);
response.getOutputStream().flush();
continuation.complete();
asyncContext.complete();
} catch (InterruptedException e) {
logger.error(e.getMessage(), e);
} catch (IOException e) {
Expand Down
Expand Up @@ -193,7 +193,7 @@ public void testVisitPostContents() {

@Test
public void transferToShouldWriteStringPart() throws IOException, URISyntaxException {
String text = FileUtils.readFileToString(TestUtils.resourceAsFile("test_sample_message.eml"));
String text = FileUtils.readFileToString(TestUtils.resourceAsFile("test_sample_message.eml"), UTF_8);

List<Part> parts = new ArrayList<>();
parts.add(new StringPart("test_sample_message.eml", text));
Expand Down

0 comments on commit 3975e72

Please sign in to comment.