Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5634 unit testing #5658

Merged
merged 11 commits into from Mar 18, 2019
177 changes: 87 additions & 90 deletions pom.xml
Expand Up @@ -3,19 +3,17 @@
<modelVersion>4.0.0</modelVersion>
<!--
If you are doing more than bumping the version number, please read
doc/sphinx-guides/source/developers/dependencies.rst
doc/sphinx-guides/source/developers/dependencies.rst
-->
<groupId>edu.harvard.iq</groupId>
<artifactId>dataverse</artifactId>
<version>4.11</version>
<packaging>war</packaging>

<name>dataverse</name>

<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<additionalparam>-Xdoclint:none</additionalparam>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<additionalparam>-Xdoclint:none</additionalparam>
<!-- Needed to avoid IDEA IDE compilation failures. See commits in GH #5059 -->
<compilerArgument></compilerArgument>
<project.timezone>UTC</project.timezone>
Expand All @@ -26,12 +24,10 @@
This seems to play well with NetBeans 8.2, IDEA 2018.1 and mvn including compatibility with JaCoCo.
-->
<argLine>-Duser.timezone=${project.timezone} -Dfile.encoding=${project.build.sourceEncoding} -Duser.language=${project.language} -Duser.region=${project.region}</argLine>

<aws.version>1.11.172</aws.version>
<jackson.version>2.9.6</jackson.version>
<commons.logging.version>1.2</commons.logging.version>
<httpcomponents.client.version>4.5.5</httpcomponents.client.version>

<junit.version>4.12</junit.version>
<junit.jupiter.version>5.3.1</junit.jupiter.version>
<junit.vintage.version>5.3.1</junit.vintage.version>
Expand All @@ -44,7 +40,6 @@
-->
<jacoco.version>0.8.1</jacoco.version>
</properties>

<!--Maven checks for dependendies from these repos in the order shown in the pom.xml
This isn't well documented and seems to change between maven versions -MAD 4.9.4 -->
<repositories>
Expand Down Expand Up @@ -76,7 +71,6 @@
<url>file://${project.basedir}/local_lib</url>
</repository>
</repositories>

<!-- Transitive dependencies, bigger library "bill of materials" (BOM) and
versions of dependencies used both directly and transitive are managed here. -->
<dependencyManagement>
Expand Down Expand Up @@ -107,7 +101,6 @@
</dependency>
</dependencies>
</dependencyManagement>

<!-- Declare any DIRECT dependencies here.
In case the depency is both transitive and direct (e. g. some common lib for logging),
manage the version above and add the direct dependency here WITHOUT version tag, too.
Expand Down Expand Up @@ -137,6 +130,12 @@
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
Expand Down Expand Up @@ -180,10 +179,10 @@
<version>1.1-SNAPSHOT</version>
<type>war</type>
<exclusions>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand Down Expand Up @@ -471,7 +470,7 @@
<artifactId>commons-codec</artifactId>
<version>1.9</version>
</dependency>
<!-- JavaSwift/JOSS: for accessing OpenStack cloud storage -->
<!-- JavaSwift/JOSS: for accessing OpenStack cloud storage -->
<dependency>
<groupId>org.javaswift</groupId>
<artifactId>joss</artifactId>
Expand Down Expand Up @@ -503,27 +502,27 @@
<artifactId>scribejava-apis</artifactId>
<version>3.1.0</version>
</dependency>
<!-- EXPERIMENTAL: -->
<!-- lyncode xoai OAI-PMH implementation: -->
<!-- unfortunately, their 4.10 version -->
<!-- is still buggy. As an experiment, I'm using -->
<!-- a patched version I built locally. -->
<!-- (pull requests pending - L.A. -->
<dependency>
<groupId>com.lyncode</groupId>
<artifactId>xoai-common</artifactId>
<version>4.1.0-header-patch</version>
</dependency>
<dependency>
<groupId>com.lyncode</groupId>
<artifactId>xoai-data-provider</artifactId>
<version>4.1.0-header-patch</version>
</dependency>
<dependency>
<groupId>com.lyncode</groupId>
<artifactId>xoai-service-provider</artifactId>
<version>4.1.0-header-patch</version>
</dependency>
<!-- EXPERIMENTAL: -->
<!-- lyncode xoai OAI-PMH implementation: -->
<!-- unfortunately, their 4.10 version -->
<!-- is still buggy. As an experiment, I'm using -->
<!-- a patched version I built locally. -->
<!-- (pull requests pending - L.A. -->
<dependency>
<groupId>com.lyncode</groupId>
<artifactId>xoai-common</artifactId>
<version>4.1.0-header-patch</version>
</dependency>
<dependency>
<groupId>com.lyncode</groupId>
<artifactId>xoai-data-provider</artifactId>
<version>4.1.0-header-patch</version>
</dependency>
<dependency>
<groupId>com.lyncode</groupId>
<artifactId>xoai-service-provider</artifactId>
<version>4.1.0-header-patch</version>
</dependency>
<!-- Added for AutoService -->
<dependency>
<groupId>com.google.auto.service</groupId>
Expand All @@ -534,61 +533,60 @@
</dependency>
<!-- For API File Upload: 1 of 2 -->
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.23.2</version>
</dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.23.2</version>
</dependency>
<!-- For API File Upload: 2 of 2 -->
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>2.23.2</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>2.23.2</version>
</dependency>
<dependency>
<groupId>com.mashape.unirest</groupId>
<artifactId>unirest-java</artifactId>
<version>1.4.9</version>
</dependency>
<!-- BagIt export -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.18</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.18</version>
</dependency>
<dependency>
<groupId>org.duracloud</groupId>
<artifactId>common</artifactId>
<version>4.4.6</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.duracloud</groupId>
<artifactId>storeclient</artifactId>
<version>4.4.6</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-sqs</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-sqs</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>

</dependency>
<dependency>
<groupId>commons-cli</groupId>
Expand All @@ -602,14 +600,13 @@
<version>1.19</version>
</dependency>
</dependencies>

<build>
<!-- <testResources>
<!-- <testResources>
<testResource>
<directory>${project.basedir}/src/main/resources</directory>
</testResource>
</testResources>-->
<!-- <testResources>
<!-- <testResources>
<testResource>
<directory>${project.basedir}/src/test/java</directory>
<excludes>
Expand Down Expand Up @@ -670,7 +667,7 @@
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<attachClasses>true</attachClasses>
<attachClasses>true</attachClasses>
<failOnMissingWebXml>false</failOnMissingWebXml>
<archive>
<manifest>
Expand Down Expand Up @@ -796,20 +793,20 @@
</plugins>
</build>
<profiles>
<profile>
<id>dev</id>
<activation>
<!-- https://stackoverflow.com/questions/11824328/default-build-profile-for-maven -->
<!-- We set dev to true to developers don't have to run non-essential tests over and over. -->
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<testsToExclude>edu.harvard.iq.dataverse.NonEssentialTests</testsToExclude>
</properties>
</profile>
<profile>
<id>all-unit-tests</id>
</profile>
<!-- TODO: Add a profile to run API tests (integration tests that end in IT.java. See conf/docker-aio/run-test-suite.sh -->
<profile>
<id>dev</id>
<activation>
<!-- https://stackoverflow.com/questions/11824328/default-build-profile-for-maven -->
<!-- We set dev to true to developers don't have to run non-essential tests over and over. -->
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<testsToExclude>edu.harvard.iq.dataverse.NonEssentialTests</testsToExclude>
</properties>
</profile>
<profile>
<id>all-unit-tests</id>
</profile>
<!-- TODO: Add a profile to run API tests (integration tests that end in IT.java. See conf/docker-aio/run-test-suite.sh -->
</profiles>
</project>
30 changes: 15 additions & 15 deletions src/main/java/edu/harvard/iq/dataverse/dataaccess/DataAccess.java
Expand Up @@ -35,7 +35,7 @@ public DataAccess() {


public static final String DEFAULT_STORAGE_DRIVER_IDENTIFIER = System.getProperty("dataverse.files.storage-driver-id");

// The getStorageIO() methods initialize StorageIO objects for
// datafiles that are already saved using one of the supported Dataverse
// DataAccess IO drivers.
Expand All @@ -45,7 +45,7 @@ public static <T extends DvObject> StorageIO<T> getStorageIO(T dvObject) throws

//passing DVObject instead of a datafile to accomodate for use of datafiles as well as datasets
public static <T extends DvObject> StorageIO<T> getStorageIO(T dvObject, DataAccessRequest req) throws IOException {

if (dvObject == null
|| dvObject.getStorageIdentifier() == null
|| dvObject.getStorageIdentifier().isEmpty()) {
Expand All @@ -57,34 +57,34 @@ public static <T extends DvObject> StorageIO<T> getStorageIO(T dvObject, DataAcc
return new FileAccessIO<>(dvObject, req);
} else if (dvObject.getStorageIdentifier().startsWith("swift://")){
return new SwiftAccessIO<>(dvObject, req);
} else if (dvObject.getStorageIdentifier().startsWith("s3://")){
} else if (dvObject.getStorageIdentifier().startsWith("s3://")){
return new S3AccessIO<>(dvObject, req);
} else if (dvObject.getStorageIdentifier().startsWith("tmp://")) {
throw new IOException("DataAccess IO attempted on a temporary file that hasn't been permanently saved yet.");
}
// TODO:
// This code will need to be extended with a system of looking up
// available storage plugins by the storage tag embedded in the
// "storage identifier".

// TODO:
// This code will need to be extended with a system of looking up
// available storage plugins by the storage tag embedded in the
// "storage identifier".
// -- L.A. 4.0.2


throw new IOException("getDataAccessObject: Unsupported storage method.");
}
// Experimental extension of the StorageIO system allowing direct access to

// Experimental extension of the StorageIO system allowing direct access to
// stored physical files that may not be associated with any DvObjects

public static StorageIO getDirectStorageIO(String storageLocation) throws IOException {
if (storageLocation.startsWith("file://")) {
return new FileAccessIO(storageLocation.substring(7));
} else if (storageLocation.startsWith("swift://")){
return new SwiftAccessIO<>(storageLocation.substring(8));
} else if (storageLocation.startsWith("s3://")){
} else if (storageLocation.startsWith("s3://")){
return new S3AccessIO<>(storageLocation.substring(5));
}

throw new IOException("getDirectStorageIO: Unsupported storage method.");
}

Expand Down Expand Up @@ -123,6 +123,6 @@ public static <T extends DvObject> StorageIO<T> createNewStorageIO(T dvObject, S
storageIO.open(DataAccessOption.WRITE_ACCESS);
return storageIO;
}


}