Merge pull request #42 from overleaf/revert-41-revert-39-msw-update-deps

Revert "Revert "Update dependencies to latest stable versions""
This commit is contained in:
Michael Walker
2018-02-27 11:51:41 +00:00
committed by GitHub
10 changed files with 80 additions and 115 deletions
+46 -26
View File
@@ -12,18 +12,20 @@
</properties> </properties>
<build> <build>
<plugins> <plugins>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
<plugin> <plugin>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version> <version>3.7.0</version>
<configuration> <configuration>
<source>1.8</source> <source>1.8</source>
<target>1.8</target> <target>1.8</target>
<compilerArgument></compilerArgument> <compilerArgument></compilerArgument>
</configuration> </configuration>
</plugin> </plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-assembly-plugin -->
<plugin> <plugin>
<artifactId>maven-assembly-plugin</artifactId> <artifactId>maven-assembly-plugin</artifactId>
<version>2.5.2</version> <version>3.1.0</version>
<executions> <executions>
<execution> <execution>
<phase>package</phase> <phase>package</phase>
@@ -46,123 +48,141 @@
</plugins> </plugins>
</build> </build>
<dependencies> <dependencies>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>4.12</version> <version>4.12</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.jmock/jmock-junit4 -->
<dependency> <dependency>
<groupId>org.jmock</groupId> <groupId>org.jmock</groupId>
<artifactId>jmock-junit4</artifactId> <artifactId>jmock-junit4</artifactId>
<version>2.8.2</version> <version>2.8.4</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-servlet -->
<dependency> <dependency>
<groupId>org.eclipse.jetty</groupId> <groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId> <artifactId>jetty-servlet</artifactId>
<version>9.3.9.v20160517</version> <version>9.4.8.v20171121</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-server -->
<dependency> <dependency>
<groupId>org.eclipse.jetty</groupId> <groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId> <artifactId>jetty-server</artifactId>
<version>9.3.9.v20160517</version> <version>9.4.8.v20171121</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency> <dependency>
<groupId>com.google.code.gson</groupId> <groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId> <artifactId>gson</artifactId>
<version>2.6.2</version> <version>2.8.2</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.asynchttpclient/async-http-client -->
<dependency> <dependency>
<groupId>com.ning</groupId> <groupId>org.asynchttpclient</groupId>
<artifactId>async-http-client</artifactId> <artifactId>async-http-client</artifactId>
<version>1.9.38</version> <version>2.3.0</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.eclipse.jgit/org.eclipse.jgit -->
<dependency> <dependency>
<groupId>org.eclipse.jgit</groupId> <groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId> <artifactId>org.eclipse.jgit</artifactId>
<version>4.4.1.201607150455-r</version> <version>4.10.0.201712302008-r</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.eclipse.jgit/org.eclipse.jgit.http.server -->
<dependency> <dependency>
<groupId>org.eclipse.jgit</groupId> <groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit.http.server</artifactId> <artifactId>org.eclipse.jgit.http.server</artifactId>
<version>4.4.1.201607150455-r</version> <version>4.10.0.201712302008-r</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc -->
<dependency> <dependency>
<groupId>org.xerial</groupId> <groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId> <artifactId>sqlite-jdbc</artifactId>
<version>3.8.11.2</version> <version>3.21.0.1</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/joda-time/joda-time -->
<dependency> <dependency>
<groupId>joda-time</groupId> <groupId>joda-time</groupId>
<artifactId>joda-time</artifactId> <artifactId>joda-time</artifactId>
<version>2.9.4</version> <version>2.9.9</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/com.google.oauth-client/google-oauth-client -->
<dependency> <dependency>
<groupId>com.google.oauth-client</groupId> <groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client</artifactId> <artifactId>google-oauth-client</artifactId>
<version>1.22.0</version> <version>1.23.0</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/com.google.http-client/google-http-client -->
<dependency> <dependency>
<groupId>com.google.http-client</groupId> <groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId> <artifactId>google-http-client</artifactId>
<version>1.22.0</version> <version>1.23.0</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/com.google.http-client/google-http-client-gson -->
<dependency> <dependency>
<groupId>com.google.http-client</groupId> <groupId>com.google.http-client</groupId>
<artifactId>google-http-client-gson</artifactId> <artifactId>google-http-client-gson</artifactId>
<version>1.22.0</version> <version>1.23.0</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency> <dependency>
<groupId>commons-lang</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-lang</artifactId> <artifactId>commons-lang3</artifactId>
<version>2.6</version> <version>3.7</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic -->
<dependency> <dependency>
<groupId>ch.qos.logback</groupId> <groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId> <artifactId>logback-classic</artifactId>
<version>1.1.7</version> <version>1.2.3</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
<version>19.0</version> <version>24.0-jre</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.mock-server/mockserver-netty -->
<dependency> <dependency>
<groupId>org.mock-server</groupId> <groupId>org.mock-server</groupId>
<artifactId>mockserver-netty</artifactId> <artifactId>mockserver-netty</artifactId>
<version>3.10.4</version> <version>5.3.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core --> <!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-core</artifactId>
<version>1.10.19</version> <version>2.13.0</version>
<scope>test</scope>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk --> <!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk -->
<dependency> <dependency>
<groupId>com.amazonaws</groupId> <groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId> <artifactId>aws-java-sdk</artifactId>
<version>1.11.28</version> <version>1.11.274</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient --> <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId> <artifactId>httpclient</artifactId>
<version>4.5.2</version> <version>4.5.5</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io --> <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency> <dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
<version>2.5</version> <version>2.6</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-compress --> <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-compress -->
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId> <artifactId>commons-compress</artifactId>
<version>1.12</version> <version>1.15</version>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>
@@ -1,6 +1,6 @@
package uk.ac.ic.wlgitbridge.bridge.resource; package uk.ac.ic.wlgitbridge.bridge.resource;
import com.ning.http.client.AsyncHttpClient; import static org.asynchttpclient.Dsl.*;
import uk.ac.ic.wlgitbridge.bridge.db.DBStore; import uk.ac.ic.wlgitbridge.bridge.db.DBStore;
import uk.ac.ic.wlgitbridge.data.filestore.RawFile; import uk.ac.ic.wlgitbridge.data.filestore.RawFile;
import uk.ac.ic.wlgitbridge.data.filestore.RepositoryFile; import uk.ac.ic.wlgitbridge.data.filestore.RepositoryFile;
@@ -31,7 +31,7 @@ public class UrlResourceCache implements ResourceCache {
} }
public UrlResourceCache(DBStore dbStore) { public UrlResourceCache(DBStore dbStore) {
this(dbStore, new NingHttpClient(new AsyncHttpClient())); this(dbStore, new NingHttpClient(asyncHttpClient()));
} }
@Override @Override
@@ -82,8 +82,7 @@ public class UrlResourceCache implements ResourceCache {
Log.info("GET -> " + url); Log.info("GET -> " + url);
try { try {
contents = http.get(url, hs -> { contents = http.get(url, hs -> {
List<String> contentLengths List<String> contentLengths = hs.getAll("Content-Length");
= hs.getHeaders().get("Content-Length");
if (!maxFileSize.isPresent()) { if (!maxFileSize.isPresent()) {
return true; return true;
} }
@@ -1,8 +1,9 @@
package uk.ac.ic.wlgitbridge.bridge.swap.store; package uk.ac.ic.wlgitbridge.bridge.swap.store;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials; import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client; import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.model.*; import com.amazonaws.services.s3.model.*;
import java.io.InputStream; import java.io.InputStream;
@@ -29,7 +30,7 @@ public class S3SwapStore implements SwapStore {
String secret, String secret,
String bucketName String bucketName
) { ) {
s3 = new AmazonS3Client(new BasicAWSCredentials(accessKey, secret)); s3 = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, secret))).build();
this.bucketName = bucketName; this.bucketName = bucketName;
} }
@@ -1,6 +1,7 @@
package uk.ac.ic.wlgitbridge.io.http.ning; package uk.ac.ic.wlgitbridge.io.http.ning;
import com.ning.http.client.*; import io.netty.handler.codec.http.HttpHeaders;
import org.asynchttpclient.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import uk.ac.ic.wlgitbridge.util.FunctionT; import uk.ac.ic.wlgitbridge.util.FunctionT;
@@ -23,7 +24,7 @@ public class NingHttpClient implements NingHttpClientFacade {
@Override @Override
public <E extends Exception> byte[] get( public <E extends Exception> byte[] get(
String url, String url,
FunctionT<HttpResponseHeaders, Boolean, E> handler FunctionT<HttpHeaders, Boolean, E> handler
) throws ExecutionException { ) throws ExecutionException {
try { try {
return http return http
@@ -33,19 +34,19 @@ public class NingHttpClient implements NingHttpClientFacade {
ByteArrayOutputStream bytes = new ByteArrayOutputStream(); ByteArrayOutputStream bytes = new ByteArrayOutputStream();
@Override @Override
public STATE onHeadersReceived( public State onHeadersReceived(
HttpResponseHeaders headers HttpHeaders headers
) throws E { ) throws E {
return handler.apply(headers) return handler.apply(headers)
? STATE.CONTINUE : STATE.ABORT; ? State.CONTINUE : State.ABORT;
} }
@Override @Override
public STATE onBodyPartReceived( public State onBodyPartReceived(
HttpResponseBodyPart content HttpResponseBodyPart content
) throws IOException { ) throws IOException {
bytes.write(content.getBodyPartBytes()); bytes.write(content.getBodyPartBytes());
return STATE.CONTINUE; return State.CONTINUE;
} }
@Override @Override
@@ -1,6 +1,6 @@
package uk.ac.ic.wlgitbridge.io.http.ning; package uk.ac.ic.wlgitbridge.io.http.ning;
import com.ning.http.client.HttpResponseHeaders; import io.netty.handler.codec.http.HttpHeaders;
import uk.ac.ic.wlgitbridge.util.FunctionT; import uk.ac.ic.wlgitbridge.util.FunctionT;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
@@ -16,7 +16,7 @@ public interface NingHttpClientFacade {
*/ */
<E extends Exception> byte[] get( <E extends Exception> byte[] get(
String url, String url,
FunctionT<HttpResponseHeaders, Boolean, E> handler FunctionT<HttpHeaders, Boolean, E> handler
) throws ExecutionException; ) throws ExecutionException;
} }
@@ -1,46 +0,0 @@
package uk.ac.ic.wlgitbridge.io.http.ning;
import com.ning.http.client.FluentCaseInsensitiveStringsMap;
import com.ning.http.client.HttpResponseHeaders;
import java.util.*;
public class NingHttpHeaders extends HttpResponseHeaders {
private final FluentCaseInsensitiveStringsMap map;
private NingHttpHeaders(FluentCaseInsensitiveStringsMap map) {
this.map = map;
}
public static NingHttpHeadersBuilder builder() {
return new NingHttpHeadersBuilder();
}
@Override
public FluentCaseInsensitiveStringsMap getHeaders() {
return map;
}
public static class NingHttpHeadersBuilder {
private final Map<String, Collection<String>> map;
private NingHttpHeadersBuilder() {
map = new HashMap<>();
}
public NingHttpHeadersBuilder addHeader(String key, String... values) {
map.computeIfAbsent(key, __ -> new ArrayList<>())
.addAll(Arrays.asList(values));
return this;
}
public NingHttpHeaders build() {
return new NingHttpHeaders(
new FluentCaseInsensitiveStringsMap(map));
}
}
}
@@ -3,7 +3,8 @@ package uk.ac.ic.wlgitbridge.snapshot.base;
import com.google.api.client.http.*; import com.google.api.client.http.*;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.ning.http.client.AsyncHttpClient; import org.asynchttpclient.AsyncHttpClient;
import static org.asynchttpclient.Dsl.*;
import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException; import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException;
import uk.ac.ic.wlgitbridge.util.Instance; import uk.ac.ic.wlgitbridge.util.Instance;
import uk.ac.ic.wlgitbridge.util.Log; import uk.ac.ic.wlgitbridge.util.Log;
@@ -17,7 +18,7 @@ import java.util.concurrent.*;
*/ */
public abstract class Request<T extends Result> { public abstract class Request<T extends Result> {
public static final AsyncHttpClient httpClient = new AsyncHttpClient(); public static final AsyncHttpClient httpClient = asyncHttpClient();
private static final Executor executor = Executors.newCachedThreadPool(); private static final Executor executor = Executors.newCachedThreadPool();
@@ -2,7 +2,7 @@ package uk.ac.ic.wlgitbridge.snapshot.servermock.server;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.ning.http.client.AsyncHttpClient; import static org.asynchttpclient.Dsl.*;
import uk.ac.ic.wlgitbridge.util.Log; import uk.ac.ic.wlgitbridge.util.Log;
import java.io.IOException; import java.io.IOException;
@@ -30,17 +30,9 @@ public class PostbackThread extends Thread {
@Override @Override
public void run() { public void run() {
try { try {
new AsyncHttpClient().preparePost( asyncHttpClient().preparePost(
url url
).setBody(postback).execute().get().getResponseBody(); ).setBody(postback).execute().get().getResponseBody();
} catch (IOException e) {
Log.warn(
"IOException on postback, url: " +
url +
", postback: " +
postback,
e
);
} catch (InterruptedException e) { } catch (InterruptedException e) {
Log.warn( Log.warn(
"Interrupted on postback, url: " + "Interrupted on postback, url: " +
@@ -1,9 +1,9 @@
package uk.ac.ic.wlgitbridge.application; 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.FileUtils;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import static org.asynchttpclient.Dsl.*;
import org.asynchttpclient.*;
import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.GitAPIException;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
@@ -613,22 +613,22 @@ public class WLGitBridgeIntegrationTest {
// With no key, we should get a 404. // With no key, we should get a 404.
String url = "http://127.0.0.1:" + gitBridgePort + "/api/testproj/push.tex"; 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()); assertEquals(404, response.getStatusCode());
// With an invalid project and no key, we should get a 404. // With an invalid project and no key, we should get a 404.
url = "http://127.0.0.1:" + gitBridgePort + "/api/notavalidproject/push.tex"; 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()); assertEquals(404, response.getStatusCode());
// With a bad key for a valid project, we should get a 404. // 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"; 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()); assertEquals(404, response.getStatusCode());
// With a bad key for an invalid project, we should get a 404. // 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"; 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()); assertEquals(404, response.getStatusCode());
wlgb.stop(); wlgb.stop();
@@ -719,14 +719,14 @@ public class WLGitBridgeIntegrationTest {
// With an invalid project and no key, we should get a 404, // With an invalid project and no key, we should get a 404,
// which is rendered by our custom error handler. // which is rendered by our custom error handler.
String url = "http://127.0.0.1:" + gitBridgePort + "/api/notavalidproject/main.tex"; 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(404, response.getStatusCode());
assertEquals("{\"message\":\"HTTP error 404\"}", response.getResponseBody()); assertEquals("{\"message\":\"HTTP error 404\"}", response.getResponseBody());
// With an unsupported URL outside the api, we should get a 500, // With an unsupported URL outside the api, we should get a 500,
// which is rendered by our custom error handler. // which is rendered by our custom error handler.
url = "http://127.0.0.1:" + gitBridgePort + "/foo"; 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(500, response.getStatusCode());
assertEquals("{\"message\":\"HTTP error 500\"}", response.getResponseBody()); assertEquals("{\"message\":\"HTTP error 500\"}", response.getResponseBody());
@@ -1,12 +1,12 @@
package uk.ac.ic.wlgitbridge.bridge.resource; 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 org.junit.Test;
import uk.ac.ic.wlgitbridge.bridge.db.noop.NoopDbStore; import uk.ac.ic.wlgitbridge.bridge.db.noop.NoopDbStore;
import uk.ac.ic.wlgitbridge.bridge.util.CastUtil; import uk.ac.ic.wlgitbridge.bridge.util.CastUtil;
import uk.ac.ic.wlgitbridge.git.exception.SizeLimitExceededException; 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.NingHttpClientFacade;
import uk.ac.ic.wlgitbridge.io.http.ning.NingHttpHeaders;
import uk.ac.ic.wlgitbridge.util.FunctionT; import uk.ac.ic.wlgitbridge.util.FunctionT;
import java.io.IOException; import java.io.IOException;
@@ -31,11 +31,8 @@ public class UrlResourceCacheTest {
private final UrlResourceCache cache private final UrlResourceCache cache
= new UrlResourceCache(new NoopDbStore(), http); = new UrlResourceCache(new NoopDbStore(), http);
private static HttpResponseHeaders withContentLength(long cl) { private static HttpHeaders withContentLength(long cl) {
return NingHttpHeaders return new DefaultHttpHeaders().add("Content-Length", String.valueOf(cl));
.builder()
.addHeader("Content-Length", String.valueOf(cl))
.build();
} }
private void respondWithContentLength(long cl, long actual) private void respondWithContentLength(long cl, long actual)
@@ -44,7 +41,7 @@ public class UrlResourceCacheTest {
Object[] args = invoc.getArguments(); Object[] args = invoc.getArguments();
//noinspection unchecked //noinspection unchecked
((FunctionT< ((FunctionT<
HttpResponseHeaders, Boolean, SizeLimitExceededException HttpHeaders, Boolean, SizeLimitExceededException
>) args[1]).apply(withContentLength(cl)); >) args[1]).apply(withContentLength(cl));
return new byte[CastUtil.assumeInt(actual)]; return new byte[CastUtil.assumeInt(actual)];
}); });