Skip to content

Commit

Permalink
Applies misc. cleanup as part of a vain effort to get the ITs to pass.
Browse files Browse the repository at this point in the history
  • Loading branch information
Edwin Shin committed May 31, 2013
1 parent 792b74d commit e31b4c2
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 48 deletions.
33 changes: 10 additions & 23 deletions src/test/java/org/fcrepo/federation/bagit/AbstractResourceIT.java
Expand Up @@ -9,11 +9,11 @@
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.PoolingClientConnectionManager;
import org.apache.http.util.EntityUtils;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
Expand Down Expand Up @@ -56,33 +56,15 @@ protected static HttpPost postObjMethod(final String pid) {
return new HttpPost(serverAddress + "objects/" + pid);
}

protected static HttpPost
postObjMethod(final String pid, final String query) {
if (query == null || query.equals("")) {
return new HttpPost(serverAddress + "objects/" + pid);
} else {
return new HttpPost(serverAddress + "objects/" + pid + "?" + query);
}
}

protected static HttpPost postDSMethod(final String pid, final String ds,
final String content) throws UnsupportedEncodingException {
final HttpPost post =
new HttpPost(serverAddress + "objects/" + pid +
"/datastreams/" + ds);
new HttpPost(serverAddress + "objects/" + pid + "/" + ds +
"/fcr:content");
post.setEntity(new StringEntity(content));
return post;
}

protected static HttpPut putDSMethod(final String pid, final String ds,
final String content) throws UnsupportedEncodingException {
final HttpPut put =
new HttpPut(serverAddress + "objects/" + pid + "/datastreams/" +
ds);
put.setEntity(new StringEntity(content));
return put;
}

protected HttpResponse execute(final HttpUriRequest method)
throws ClientProtocolException, IOException {
logger.debug("Executing: " + method.getMethod() + " to " +
Expand All @@ -92,6 +74,11 @@ protected HttpResponse execute(final HttpUriRequest method)

protected int getStatus(final HttpUriRequest method)
throws ClientProtocolException, IOException {
return execute(method).getStatusLine().getStatusCode();
HttpResponse response = execute(method);
int result = response.getStatusLine().getStatusCode();
if (!(result > 199) || !(result < 400)) {
logger.warn(EntityUtils.toString(response.getEntity()));
}
return result;
}
}
}
19 changes: 9 additions & 10 deletions src/test/resources/spring-test/master.xml
@@ -1,13 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<!-- Master context for the test application. -->
<import resource="classpath:/spring-test/repo.xml"/>
<import resource="classpath:/spring-test/rest.xml"/>
<import resource="classpath:/spring-test/eventing.xml"/>

<!-- Master context for the test application. -->

<import resource="classpath:spring-test/repo.xml" />
<import resource="classpath:spring-test/rest.xml" />
<import resource="classpath:spring-test/eventing.xml" />

</beans>
25 changes: 12 additions & 13 deletions src/test/resources/spring-test/rest.xml
@@ -1,18 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<bean class="org.fcrepo.session.SessionFactory" />

<!-- Mints PIDs-->
<bean class="org.fcrepo.identifiers.UUIDPidMinter"/>

<context:annotation-config />

<context:component-scan base-package="org.fcrepo.api, org.fcrepo.exceptionhandlers"/>
<context:property-placeholder />
<context:annotation-config />

</beans>
<context:component-scan
base-package="org.modeshape.web.jcr.rest, org.fcrepo.api, org.fcrepo.serialization, org.fcrepo.responses, org.fcrepo.exceptionhandlers" />

<!-- Mints PIDs -->
<bean class="org.fcrepo.identifiers.UUIDPidMinter" />
<bean class="org.fcrepo.session.SessionFactory" />
</beans>
3 changes: 2 additions & 1 deletion src/test/resources/spring-test/test-container.xml
Expand Up @@ -6,6 +6,7 @@
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<context:property-placeholder/>
<context:annotation-config/>

<!-- show stack traces for easier debugging -->
<bean id="wildcardExceptionmapper" class="org.fcrepo.exceptionhandlers.WildcardExceptionMapper" >
Expand All @@ -15,7 +16,7 @@
<bean id="containerWrapper" class="org.fcrepo.test.util.ContainerWrapper" init-method="start" destroy-method="stop" >
<property name="port" value="${test.port:8080}"/>
<property name="contextConfigLocations" value="classpath:spring-test/master.xml" />
<property name="packagesToScan" value="org.fcrepo.api, org.fcrepo.exceptionhandlers" />
<property name="packagesToScan" value="org.fcrepo.api, org.fcrepo.exceptionhandlers, org.fcrepo.responses" />
</bean>

</beans>
2 changes: 1 addition & 1 deletion src/test/resources/test_repository.json
Expand Up @@ -2,7 +2,7 @@
"name" : "repo",
"jndiName" : "",
"workspaces" : {
"predefined" : [],
"predefined" : ["default"],
"default" : "default",
"allowCreation" : true
},
Expand Down

0 comments on commit e31b4c2

Please sign in to comment.