Skip to content

Commit

Permalink
Work around limitations with buffering in the jetty component by usin…
Browse files Browse the repository at this point in the history
…g http4 instead. This problem manifests itself when API-X proxies the retrieval of large (>2MiB) resources from Fedora. (fcrepo4-labs#77)

- Use http4 component instead of jetty in the 'execute-intercept' route
- Includes IT demonstrating the issue whe the jetty component is used
  • Loading branch information
emetsger committed Nov 10, 2016
1 parent 809db12 commit 5023908
Show file tree
Hide file tree
Showing 8 changed files with 433 additions and 4 deletions.
7 changes: 7 additions & 0 deletions fcrepo-api-x-integration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,13 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
<scope>test</scope>
</dependency>

<!-- Fedora -->
<dependency>
<groupId>org.fcrepo</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -204,10 +205,19 @@ public default Option deployFile(String path) {
* @return the resulting WebResource
*/
public default WebResource testResource(String path) {
return testResource(path, "text/turtle");
}

/**
* Get a test resource from test-classes
*
* @param path the resource path relative to {@link #testResources}
* @return the resulting WebResource
*/
public default WebResource testResource(String path, String contentType) {
final File file = new File(testResources, path);
try {
return WebResource.of(new FileInputStream(file), "text/turtle", URI.create(FilenameUtils.getBaseName(
return WebResource.of(new FileInputStream(file), contentType, URI.create(FilenameUtils.getBaseName(
path)), null);
} catch (final Exception e) {
throw new RuntimeException(e);
Expand All @@ -225,6 +235,34 @@ public default URI postFromTestResource(final String filePath, final URI intoCon
}
}

public default URI postFromTestResource(final String filePath, final URI intoContainer, final String contentType)
throws Exception {
return postFromTestResource(filePath, intoContainer, contentType,
String.format("%s_%s", testMethodName(), getBaseName(filePath)));
}

public default URI postFromTestResource(final String filePath, final URI intoContainer,
final String contentType, final String slug) throws Exception {
try (final WebResource object = testResource(filePath, contentType);
final FcrepoResponse response = client.post(intoContainer)
.body(object.representation(), object.contentType())
.slug(slug)
.perform()) {
return response.getLocation();
}
}

public default URI postFromStream(final InputStream in, final URI intoContainer, final String contentType,
final String slug) throws Exception {
try (final WebResource object = WebResource.of(in, contentType);
final FcrepoResponse response = client.post(intoContainer)
.body(object.representation(), object.contentType())
.slug(slug)
.perform()) {
return response.getLocation();
}
}

public static <T> T attempt(final int times, final Callable<T> it) {

Exception caught = null;
Expand Down
Loading

0 comments on commit 5023908

Please sign in to comment.