Ensure SWORD integration tests only run if SWORDWebConfig is loaded

This commit is contained in:
Tim Donohue
2019-01-31 22:28:52 +00:00
parent 56f7cb11bc
commit 6f51195e6c
3 changed files with 21 additions and 0 deletions

View File

@@ -259,6 +259,8 @@
<artifactId>dspace-services</artifactId> <artifactId>dspace-services</artifactId>
</dependency> </dependency>
<!-- DSpace modules to deploy (this modules are all optional, but add features/endpoints to webapp) -->
<!-- You may choose to comment out any of these modules if you do not want/need its features -->
<dependency> <dependency>
<groupId>org.dspace</groupId> <groupId>org.dspace</groupId>
<artifactId>dspace-sword</artifactId> <artifactId>dspace-sword</artifactId>

View File

@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.embedded.LocalServerPort; import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.context.ApplicationContext;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
@@ -52,6 +53,10 @@ public class AbstractWebClientIntegrationTest extends AbstractIntegrationTestWit
@Autowired @Autowired
private TestRestTemplate restTemplate; private TestRestTemplate restTemplate;
// Spring Application context
@Autowired
protected ApplicationContext applicationContext;
/** /**
* Get client TestRestTemplate for making HTTP requests to test webserver * Get client TestRestTemplate for making HTTP requests to test webserver
* @return TestRestTemplate * @return TestRestTemplate

View File

@@ -13,6 +13,8 @@ import static org.junit.Assert.assertThat;
import org.dspace.app.rest.test.AbstractWebClientIntegrationTest; import org.dspace.app.rest.test.AbstractWebClientIntegrationTest;
import org.dspace.services.ConfigurationService; import org.dspace.services.ConfigurationService;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -34,6 +36,18 @@ public class Swordv1IT extends AbstractWebClientIntegrationTest {
@Autowired @Autowired
private ConfigurationService configurationService; private ConfigurationService configurationService;
@Before
public void onlyRunIfConfigExists() {
// These integration tests REQUIRE that SWORDWebConfig is found/available (as this class deploys SWORD)
// If this class is not available, the below "Assume" will cause all tests to be SKIPPED
// NOTE: SWORDWebConfig is provided by the 'dspace-sword' module
try {
Class.forName("org.dspace.app.configuration.SWORDWebConfig");
} catch (ClassNotFoundException ce) {
Assume.assumeNoException(ce);
}
}
@Test @Test
public void serviceDocumentUnauthorizedTest() throws Exception { public void serviceDocumentUnauthorizedTest() throws Exception {
// Attempt to load the ServiceDocument without first authenticating // Attempt to load the ServiceDocument without first authenticating