mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Ensure SWORD integration tests only run if SWORDWebConfig is loaded
This commit is contained in:
@@ -259,6 +259,8 @@
|
||||
<artifactId>dspace-services</artifactId>
|
||||
</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>
|
||||
<groupId>org.dspace</groupId>
|
||||
<artifactId>dspace-sword</artifactId>
|
||||
|
@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.embedded.LocalServerPort;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
@@ -52,6 +53,10 @@ public class AbstractWebClientIntegrationTest extends AbstractIntegrationTestWit
|
||||
@Autowired
|
||||
private TestRestTemplate restTemplate;
|
||||
|
||||
// Spring Application context
|
||||
@Autowired
|
||||
protected ApplicationContext applicationContext;
|
||||
|
||||
/**
|
||||
* Get client TestRestTemplate for making HTTP requests to test webserver
|
||||
* @return TestRestTemplate
|
||||
|
@@ -13,6 +13,8 @@ import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.dspace.app.rest.test.AbstractWebClientIntegrationTest;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -34,6 +36,18 @@ public class Swordv1IT extends AbstractWebClientIntegrationTest {
|
||||
@Autowired
|
||||
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
|
||||
public void serviceDocumentUnauthorizedTest() throws Exception {
|
||||
// Attempt to load the ServiceDocument without first authenticating
|
||||
|
Reference in New Issue
Block a user