Skip to content

Commit

Permalink
Clean up; remove unnecessary Fedora logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz committed Oct 12, 2021
1 parent 373ea19 commit 9584d77
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 37 deletions.
Expand Up @@ -27,8 +27,6 @@
import org.apache.camel.builder.AdviceWith;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.model.ModelCamelContext;
import org.fcrepo.client.FcrepoClient;
import org.fcrepo.client.FcrepoResponse;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
Expand All @@ -41,18 +39,13 @@
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.AnnotationConfigContextLoader;

import java.net.URI;

import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.ok;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static java.lang.Integer.parseInt;
import static org.apache.camel.util.ObjectHelper.loadResourceAsStream;
import static org.fcrepo.camel.indexing.http.integration.TestUtils.createClient;
import static org.fcrepo.camel.indexing.http.integration.TestUtils.getEvent;
import static org.fcrepo.camel.FcrepoHeaders.FCREPO_EVENT_TYPE;
import static org.slf4j.LoggerFactory.getLogger;

/**
Expand All @@ -69,8 +62,6 @@ public class RouteDeleteIT {

private static final String AS_NS = "https://www.w3.org/ns/activitystreams#";

private String fullPath = "";

private static final String MOCK_ENDPOINT= "/endpoint";

private static final String MOCKSERVER_PORT = System.getProperty(
Expand All @@ -83,6 +74,8 @@ public class RouteDeleteIT {

private static final String BASIC_AUTH_PASSWORD = "barPass";

private String fullPath = "http://localhost:" + FCREPO_PORT + "/fcrepo/rest/" + "fake-identifier";

@EndpointInject("mock:result")
protected MockEndpoint resultEndpoint;

Expand Down Expand Up @@ -115,15 +108,6 @@ public void tearDownMockServer() throws Exception {

@Before
public void setUpMockServer() throws Exception {
final FcrepoClient client = createClient();
final FcrepoResponse res = client.post(URI.create("http://localhost:" + FCREPO_PORT + "/fcrepo/rest"))
.body(loadResourceAsStream("indexable.ttl"), "text/turtle").perform();
fullPath = res.getLocation().toString();
logger.info("full path {}", fullPath);

// Delete the object we just created
client.delete(URI.create(fullPath)).perform();

mockServer = new WireMockServer(WireMockConfiguration.options().port(parseInt(MOCKSERVER_PORT)));
mockServer.start();
}
Expand All @@ -135,7 +119,7 @@ public void testDeletedResourceWithEventBody() throws Exception {
final var idMatcher = WireMock.matchingJsonPath("$.id", equalTo(fullPath));
final var typeMatcher = WireMock.matchingJsonPath("$.type", equalTo(AS_NS + "Delete"));

// have the http server return a 200
// have the http server return a 200; also test that basic auth works (for variety)
mockServer.stubFor(post(urlEqualTo(MOCK_ENDPOINT))
.withBasicAuth(BASIC_AUTH_USERNAME, BASIC_AUTH_PASSWORD)
.willReturn(ok()));
Expand Down
Expand Up @@ -29,8 +29,6 @@
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.model.ModelCamelContext;
import org.apache.camel.spring.javaconfig.CamelConfiguration;
import org.fcrepo.client.FcrepoClient;
import org.fcrepo.client.FcrepoResponse;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
Expand All @@ -52,14 +50,9 @@
import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static java.lang.Integer.parseInt;
import static org.apache.camel.util.ObjectHelper.loadResourceAsStream;
import static org.fcrepo.camel.indexing.http.integration.TestUtils.createClient;
import static org.fcrepo.camel.indexing.http.integration.TestUtils.getEvent;
import static org.fcrepo.camel.FcrepoHeaders.FCREPO_EVENT_TYPE;
import static org.slf4j.LoggerFactory.getLogger;

import java.net.URI;

/**
* Test the route workflow.
*
Expand All @@ -74,8 +67,6 @@ public class RouteUpdateIT {

private static final String AS_NS = "https://www.w3.org/ns/activitystreams#";

private String fullPath = "";

private static final String MOCK_ENDPOINT= "/endpoint";

private static final String MOCKSERVER_PORT = System.getProperty(
Expand All @@ -87,6 +78,8 @@ public class RouteUpdateIT {
private static final String JMS_PORT = System.getProperty(
"fcrepo.dynamic.jms.port", "61616");

private String fullPath = "http://localhost:" + FCREPO_PORT + "/fcrepo/rest/" + "fake-identifier";


@EndpointInject("mock:result")
protected MockEndpoint resultEndpoint;
Expand Down Expand Up @@ -118,12 +111,6 @@ public void tearDownMockServer() {

@Before
public void setUpMockServer() throws Exception {
final FcrepoClient client = createClient();
final FcrepoResponse res = client.post(URI.create("http://localhost:" + FCREPO_PORT + "/fcrepo/rest"))
.body(loadResourceAsStream("indexable.ttl"), "text/turtle").perform();
fullPath = res.getLocation().toString();
logger.info("full path {}", fullPath);

mockServer = new WireMockServer(WireMockConfiguration.options().port(parseInt(MOCKSERVER_PORT)));
mockServer.start();
}
Expand All @@ -146,8 +133,6 @@ public void testAddedEventRouter() throws Exception {

final var mockServerMockEndpoint = MockEndpoint.resolve(camelContext, mockServerEndpoint);
mockServerMockEndpoint.expectedMessageCount(1);
// do we still need the response code header?
// mockServerMockEndpoint.expectedHeaderReceived(Exchange.HTTP_RESPONSE_CODE, 200);
final var updateEndpoint = MockEndpoint.resolve(camelContext, "mock://direct:send.to.http");
updateEndpoint.expectedMessageCount(1);

Expand All @@ -168,6 +153,5 @@ public ActiveMQComponent broker() {
component.setBrokerURL("tcp://localhost:" + JMS_PORT);
return component;
}

}
}

0 comments on commit 9584d77

Please sign in to comment.