DataONE Test Resources Package

Set of common test resources available to all DataONE packages for both unit and integration testing

License

License

Categories

Categories

Data
GroupId

GroupId

org.dataone
ArtifactId

ArtifactId

d1_test_resources
Last Version

Last Version

2.3.1
Release Date

Release Date

Type

Type

jar
Description

Description

DataONE Test Resources Package
Set of common test resources available to all DataONE packages for both unit and integration testing
Project URL

Project URL

http://dataone.org
Source Code Management

Source Code Management

https://github.com/DataONEorg/d1_test_resources

Download d1_test_resources

How to add to project

<!-- https://jarcasting.com/artifacts/org.dataone/d1_test_resources/ -->
<dependency>
    <groupId>org.dataone</groupId>
    <artifactId>d1_test_resources</artifactId>
    <version>2.3.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.dataone/d1_test_resources/
implementation 'org.dataone:d1_test_resources:2.3.1'
// https://jarcasting.com/artifacts/org.dataone/d1_test_resources/
implementation ("org.dataone:d1_test_resources:2.3.1")
'org.dataone:d1_test_resources:jar:2.3.1'
<dependency org="org.dataone" name="d1_test_resources" rev="2.3.1">
  <artifact name="d1_test_resources" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.dataone', module='d1_test_resources', version='2.3.1')
)
libraryDependencies += "org.dataone" % "d1_test_resources" % "2.3.1"
[org.dataone/d1_test_resources "2.3.1"]

Dependencies

compile (4)

Group / Artifact Type Version
junit : junit jar 4.12
org.apache.directory.server : apacheds-server-integ jar 2.0.0-M21
org.apache.directory.server : apacheds-core-integ jar 2.0.0-M21
org.apache.directory.server : apacheds-server-jndi jar 2.0.0-M21

test (9)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.5
org.slf4j : slf4j-simple jar 1.7.5
org.slf4j : jcl-over-slf4j jar 1.7.5
org.slf4j : log4j-over-slf4j jar 1.7.5
ch.qos.logback : logback-classic jar 1.0.13
org.springframework : spring-core jar 4.3.8.RELEASE
org.springframework : spring-context jar 4.3.8.RELEASE
org.springframework : spring-beans jar 4.3.8.RELEASE
org.springframework : spring-test jar 4.3.8.RELEASE

Project Modules

There are no modules declared in this project.

Java development (testing really):

Java CI

This maven package is set up as the location for DataONE common test resources to be made available for unit and integration tests. It will be listed as a dependency of d1_common_java, for transparent incorporation to java developers using the d1_*_java packages. (d1_common_java is a dependency of most, if not all so far. See d1_common_java pom.xml dependency section otherwise.)

Java Resources

It is meant that callers would use this.getClass().getResourceAsStream("relative/path/to/resource") to access the resources, and that resources will be appropriately organized in subdirectories according to usage and perhaps type.

Special rules apply to getResourceAsStream() for accessing files, so for example, to access the file:

d1_test_resources/src/main/resources/D1shared/selfTest/simpleDummyResource.txt

one would invoke the method thusly:

this.getClass().getResourceAsStream("D1shared/selfTest/simpleDummyResource.txt");

Java Classes

Classes may be added in order to supply Resource collections to unit tests or to extend Junit tests that may be used by all DataONE java components.

PackageFiles

If a collection of resources must be used instead of a single file, then the PackageFiles.java class is available for extension. As background, Introspection can be used to discover classes in a java package, but it cannot be used to discover other resources, such as xml files or ldif files. The PackageFiles.java class is a mechanism to discover resources other than classes in a package. The PackageFiles.java class to work must have a java class in the same package as the other resources to discover. Therefore, when D1 needed a collection of files from the KNB node to be used for unit testing, The PackageFiles.java class was extended in the maven directory src/main/java in the package:

org.dataone.test.knb.data

with the class:

KnbRecords.java

The xml resources where placed in the maven directory src/main/resources in the same package:

org.dataone.test.knb.data

with the xml files:

Blandy.76.2
Blandy.77.1
etc

The extension of the class also allowed for a collection of systemMetadata files to be found in the specified package:

org.dataone.test.knb.sysmeta

ApacheDSSuiteRunner

ApacheDSSuiteRunner is an extension of Junit's Suite class and is based on org.apache.directory.server.core.integ.FrameworkRunner.

The ApacheDSSuiteRunner allows for ApacheDS annotations such as @CreateDS, @ApplyLdifFiles and @CreateLdapServer to be applied to a Junit suite of tests. This allows for ApacheDS to be setup and shutdown and run only once for multiple junit test classes in a java component rather than having to setup and shutdown ApacheDS for each class executed.

ApacheDS will load a dataone-schema.ldif file in order to create a schema that ApacheDS will use as its LDAP tree. In order to generate thie dataone-schema.ldif file, you must install Apache Directory Studio (minimal 2.0.0-M9). Open up Apache Directory Studio and from the File Menu, choose New. You should choose Schema Editor and then New Schema Project. Specify the Project Name as DataONETest and confirm the option Offline Schema is choosen. Click Next. The next screen confirm that you are viewing the schemas for ApacheDS and press the button 'Select All' followed by pressing the button Finish.

You will now need to import the DataONE OpenLDAP compliant schema into ApacheDS Studio. From the File Menu, choose Import. On the Import wizard window, choose Schema Editor > Schemas from Open Ldap Files. The file you will import is in the dataone-cn-os-core package. Make certain you have https://repository.dataone.org/software/cicore/trunk/cn-buildout/dataone-cn-os-core/usr/share/dataone-cn-os-core/debian/ldap/dataone.schema downloaded. Press the Next button on the Import Wizard, on the next screen, using the Browse Button, find the directory that holds the dataone.schema file. Click on the dataone.schema file that was found. Press the Finish button.

If everything worked well, then you should see 'dataone' in the Schema Editor perspective in the Schema view. You will next Export the Dataone Schema as an Active Directory schema. From the File Menu, choose Export. On the Export wizard window, choose Schema Editor > Schemas for Apache DS. Press the Next button. Check the 'dataone' schema. You should 'Export each schema as a separate file' and choose the directory in which the dataone-schema.ldif file is located in d1_test_resources package. d1_test_resources/src/main/resources/org/dataone/test/apache/directory/server Press Finish button.

A dataone.ldif should show up in the org.dataone.test.apache.directory.server package for the main resources of the project. Diff the dataone.ldif to the data-schema.ldif file to confirm changes. Then move the dataone.ldif to the data-schema.ldif. Commit the changes and make certain to rebuild the project to test out the changes.

org.dataone

DataONE

Versions

Version
2.3.1
2.3.0