Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Using non-deprecated HTTP multipart machinery
  • Loading branch information
ajs6f committed Nov 14, 2013
1 parent 4ed0f7b commit 53762ba
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
Expand Up @@ -22,7 +22,6 @@
import org.fcrepo.http.commons.AbstractResource;
import org.fcrepo.http.commons.responses.HtmlTemplate;
import org.fcrepo.http.commons.session.InjectedSession;
import org.slf4j.Logger;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

Expand All @@ -48,7 +47,6 @@
import static org.fcrepo.http.commons.domain.RDFMediaType.RDF_JSON;
import static org.fcrepo.http.commons.domain.RDFMediaType.RDF_XML;
import static org.fcrepo.http.commons.domain.RDFMediaType.TURTLE;
import static org.slf4j.LoggerFactory.getLogger;

/**
* Expose node types at a REST endpoint
Expand All @@ -59,8 +57,6 @@
@Path("/fcr:nodetypes")
public class FedoraRepositoryNodeTypes extends AbstractResource {

private final Logger LOGGER = getLogger(FedoraRepositoryNodeTypes.class);

@InjectedSession
protected Session session;

Expand Down
Expand Up @@ -21,14 +21,15 @@
import static java.util.regex.Pattern.DOTALL;
import static java.util.regex.Pattern.compile;
import static junit.framework.TestCase.assertFalse;
import static org.apache.http.entity.ContentType.TEXT_PLAIN;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.util.EntityUtils;
import org.junit.Test;
Expand Down Expand Up @@ -66,12 +67,10 @@ public void testModifyMultipleDatastreams() throws Exception {
final HttpPost post =
new HttpPost(serverAddress
+ "FedoraDatastreamsTest8/fcr:datastreams?delete=ds_void");

final MultipartEntity multiPartEntity = new MultipartEntity();
multiPartEntity.addPart("ds1", new StringBody("asdfg"));
multiPartEntity.addPart("ds2", new StringBody("qwerty"));

post.setEntity(multiPartEntity);
final MultipartEntityBuilder multiPartEntityBuilder = MultipartEntityBuilder.create();
multiPartEntityBuilder.addPart("ds1", new StringBody("asdfg", TEXT_PLAIN));
multiPartEntityBuilder.addPart("ds2", new StringBody("qwerty", TEXT_PLAIN));
post.setEntity(multiPartEntityBuilder.build());

final HttpResponse postResponse = client.execute(post);

Expand All @@ -98,12 +97,12 @@ public void testRetrieveMultipartDatastreams() throws Exception {
final HttpPost post =
new HttpPost(serverAddress
+ "FedoraDatastreamsTest9/fcr:datastreams/");
final MultipartEntityBuilder multiPartEntityBuilder =
MultipartEntityBuilder.create().addPart("ds1",
new StringBody("asdfg", TEXT_PLAIN)).addPart("ds2",
new StringBody("qwerty", TEXT_PLAIN));

final MultipartEntity multiPartEntity = new MultipartEntity();
multiPartEntity.addPart("ds1", new StringBody("asdfg"));
multiPartEntity.addPart("ds2", new StringBody("qwerty"));

post.setEntity(multiPartEntity);
post.setEntity(multiPartEntityBuilder.build());

final HttpResponse postResponse = client.execute(post);
assertEquals(201, postResponse.getStatusLine().getStatusCode());
Expand Down Expand Up @@ -132,11 +131,12 @@ public void testRetrieveFIlteredMultipartDatastreams() throws Exception {
new HttpPost(serverAddress
+ "FedoraDatastreamsTest10/fcr:datastreams");

final MultipartEntity multiPartEntity = new MultipartEntity();
multiPartEntity.addPart("ds1", new StringBody("asdfg"));
multiPartEntity.addPart("ds2", new StringBody("qwerty"));
final MultipartEntityBuilder multiPartEntityBuilder =
MultipartEntityBuilder.create().addPart("ds1",
new StringBody("asdfg", TEXT_PLAIN)).addPart("ds2",
new StringBody("qwerty", TEXT_PLAIN));

post.setEntity(multiPartEntity);
post.setEntity(multiPartEntityBuilder.build());

final HttpResponse postResponse = client.execute(post);
assertEquals(201, postResponse.getStatusLine().getStatusCode());
Expand Down
Expand Up @@ -274,6 +274,7 @@ public void testGetObjectGraphHtml() throws Exception {
assertEquals(OK.getStatusCode(), response.getStatusLine()
.getStatusCode());
final String content = EntityUtils.toString(response.getEntity());
logger.debug("Retrieved: {}", content);
}

@Test
Expand Down
Expand Up @@ -18,7 +18,7 @@

import static com.hp.hpl.jena.rdf.model.ModelFactory.createDefaultModel;
import static java.net.URI.create;
import static junit.framework.Assert.assertNotNull;
import static org.junit.Assert.assertNotNull;
import static org.apache.jena.riot.WebContent.contentTypeToLang;
import static org.fcrepo.kernel.utils.ContentDigest.asURI;
import static org.mockito.Matchers.anyString;
Expand Down

0 comments on commit 53762ba

Please sign in to comment.