mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-24 17:51:51 +02:00
Replace com.ning/async-http-client with new package
Notice at: https://github.com/ning/async-http-client
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
package uk.ac.ic.wlgitbridge.application;
|
||||
|
||||
import com.ning.http.client.AsyncHttpClient;
|
||||
import com.ning.http.client.Response;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import static org.asynchttpclient.Dsl.*;
|
||||
import org.asynchttpclient.*;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
@@ -613,22 +613,22 @@ public class WLGitBridgeIntegrationTest {
|
||||
|
||||
// With no key, we should get a 404.
|
||||
String url = "http://127.0.0.1:" + gitBridgePort + "/api/testproj/push.tex";
|
||||
Response response = new AsyncHttpClient().prepareGet(url).execute().get();
|
||||
Response response = asyncHttpClient().prepareGet(url).execute().get();
|
||||
assertEquals(404, response.getStatusCode());
|
||||
|
||||
// With an invalid project and no key, we should get a 404.
|
||||
url = "http://127.0.0.1:" + gitBridgePort + "/api/notavalidproject/push.tex";
|
||||
response = new AsyncHttpClient().prepareGet(url).execute().get();
|
||||
response = asyncHttpClient().prepareGet(url).execute().get();
|
||||
assertEquals(404, response.getStatusCode());
|
||||
|
||||
// With a bad key for a valid project, we should get a 404.
|
||||
url = "http://127.0.0.1:" + gitBridgePort + "/api/testproj/push.tex?key=notavalidkey";
|
||||
response = new AsyncHttpClient().prepareGet(url).execute().get();
|
||||
response = asyncHttpClient().prepareGet(url).execute().get();
|
||||
assertEquals(404, response.getStatusCode());
|
||||
|
||||
// With a bad key for an invalid project, we should get a 404.
|
||||
url = "http://127.0.0.1:" + gitBridgePort + "/api/notavalidproject/push.tex?key=notavalidkey";
|
||||
response = new AsyncHttpClient().prepareGet(url).execute().get();
|
||||
response = asyncHttpClient().prepareGet(url).execute().get();
|
||||
assertEquals(404, response.getStatusCode());
|
||||
|
||||
wlgb.stop();
|
||||
@@ -719,14 +719,14 @@ public class WLGitBridgeIntegrationTest {
|
||||
// With an invalid project and no key, we should get a 404,
|
||||
// which is rendered by our custom error handler.
|
||||
String url = "http://127.0.0.1:" + gitBridgePort + "/api/notavalidproject/main.tex";
|
||||
Response response = new AsyncHttpClient().prepareGet(url).execute().get();
|
||||
Response response = asyncHttpClient().prepareGet(url).execute().get();
|
||||
assertEquals(404, response.getStatusCode());
|
||||
assertEquals("{\"message\":\"HTTP error 404\"}", response.getResponseBody());
|
||||
|
||||
// With an unsupported URL outside the api, we should get a 500,
|
||||
// which is rendered by our custom error handler.
|
||||
url = "http://127.0.0.1:" + gitBridgePort + "/foo";
|
||||
response = new AsyncHttpClient().prepareGet(url).execute().get();
|
||||
response = asyncHttpClient().prepareGet(url).execute().get();
|
||||
assertEquals(500, response.getStatusCode());
|
||||
assertEquals("{\"message\":\"HTTP error 500\"}", response.getResponseBody());
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package uk.ac.ic.wlgitbridge.bridge.resource;
|
||||
|
||||
import com.ning.http.client.HttpResponseHeaders;
|
||||
import io.netty.handler.codec.http.HttpHeaders;
|
||||
import io.netty.handler.codec.http.DefaultHttpHeaders;
|
||||
import org.junit.Test;
|
||||
import uk.ac.ic.wlgitbridge.bridge.db.noop.NoopDbStore;
|
||||
import uk.ac.ic.wlgitbridge.bridge.util.CastUtil;
|
||||
import uk.ac.ic.wlgitbridge.git.exception.SizeLimitExceededException;
|
||||
import uk.ac.ic.wlgitbridge.io.http.ning.NingHttpClientFacade;
|
||||
import uk.ac.ic.wlgitbridge.io.http.ning.NingHttpHeaders;
|
||||
import uk.ac.ic.wlgitbridge.util.FunctionT;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -31,11 +31,8 @@ public class UrlResourceCacheTest {
|
||||
private final UrlResourceCache cache
|
||||
= new UrlResourceCache(new NoopDbStore(), http);
|
||||
|
||||
private static HttpResponseHeaders withContentLength(long cl) {
|
||||
return NingHttpHeaders
|
||||
.builder()
|
||||
.addHeader("Content-Length", String.valueOf(cl))
|
||||
.build();
|
||||
private static HttpHeaders withContentLength(long cl) {
|
||||
return new DefaultHttpHeaders().add("Content-Length", String.valueOf(cl));
|
||||
}
|
||||
|
||||
private void respondWithContentLength(long cl, long actual)
|
||||
@@ -44,7 +41,7 @@ public class UrlResourceCacheTest {
|
||||
Object[] args = invoc.getArguments();
|
||||
//noinspection unchecked
|
||||
((FunctionT<
|
||||
HttpResponseHeaders, Boolean, SizeLimitExceededException
|
||||
HttpHeaders, Boolean, SizeLimitExceededException
|
||||
>) args[1]).apply(withContentLength(cl));
|
||||
return new byte[CastUtil.assumeInt(actual)];
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user