Revision 8785
Added by Lauren Walker over 10 years ago
test/edu/ucsb/nceas/metacat/annotation/OrePackageTest.java | ||
---|---|---|
47 | 47 |
|
48 | 48 |
|
49 | 49 |
private static final String ANNOTATION_TEST_DOC = "test/eml-sample-annotation.xml"; |
50 |
private static final String ANNOTATION_TEST_DATA = "test/onlineDataFile2"; |
|
50 | 51 |
|
51 | 52 |
/** |
52 | 53 |
* constructor for the test |
... | ... | |
88 | 89 |
Identifier metadataPid = new Identifier(); |
89 | 90 |
metadataPid.setValue("testOre.eml." + System.currentTimeMillis()); |
90 | 91 |
Session session = getTestSession(); |
91 |
// try { |
|
92 |
// InputStream object = new ByteArrayInputStream(this.getTestDocFromFile(ANNOTATION_TEST_DOC).getBytes("UTF-8")); |
|
93 |
// SystemMetadata sysmeta = createSystemMetadata(metadataPid, session.getSubject(), object); |
|
94 |
// ObjectFormatIdentifier formatId = new ObjectFormatIdentifier(); |
|
95 |
// formatId.setValue("eml://ecoinformatics.org/eml-2.0.0"); |
|
96 |
// sysmeta.setFormatId(formatId); |
|
97 |
// Identifier pid = MNodeService.getInstance(request).create(session, metadataPid, object, sysmeta); |
|
98 |
// assertEquals(metadataPid.getValue(), pid.getValue()); |
|
99 |
// } catch (Exception e) { |
|
100 |
// e.printStackTrace(); |
|
101 |
// fail("Could not add metadata test file: " + e.getMessage()); |
|
102 |
// } |
|
92 |
try { |
|
93 |
InputStream object = new ByteArrayInputStream(this.getTestDocFromFile(ANNOTATION_TEST_DOC).getBytes("UTF-8")); |
|
94 |
SystemMetadata sysmeta = createSystemMetadata(metadataPid, session.getSubject(), object); |
|
95 |
ObjectFormatIdentifier formatId = new ObjectFormatIdentifier(); |
|
96 |
formatId.setValue("eml://ecoinformatics.org/eml-2.0.0"); |
|
97 |
sysmeta.setFormatId(formatId); |
|
98 |
Identifier pid = MNodeService.getInstance(request).create(session, metadataPid, object, sysmeta); |
|
99 |
assertEquals(metadataPid.getValue(), pid.getValue()); |
|
100 |
} catch (Exception e) { |
|
101 |
e.printStackTrace(); |
|
102 |
fail("Could not add metadata test file: " + e.getMessage()); |
|
103 |
} |
|
104 |
|
|
105 |
// add a data file |
|
106 |
Identifier dataIdentifier = new Identifier(); |
|
107 |
dataIdentifier.setValue("derivedData." + System.currentTimeMillis()); |
|
108 |
try { |
|
109 |
InputStream object = new ByteArrayInputStream(this.getTestDocFromFile(ANNOTATION_TEST_DATA).getBytes("UTF-8")); |
|
110 |
SystemMetadata sysmeta = createSystemMetadata(dataIdentifier, session.getSubject(), object); |
|
111 |
ObjectFormatIdentifier formatId = new ObjectFormatIdentifier(); |
|
112 |
formatId.setValue("text/csv"); |
|
113 |
sysmeta.setFormatId(formatId); |
|
114 |
Identifier pid = MNodeService.getInstance(request).create(session, dataIdentifier, object, sysmeta); |
|
115 |
assertEquals(dataIdentifier.getValue(), pid.getValue()); |
|
116 |
} catch (Exception e) { |
|
117 |
e.printStackTrace(); |
|
118 |
fail("Could not add data test file: " + e.getMessage()); |
|
119 |
} |
|
103 | 120 |
|
104 | 121 |
// generate the ORE for the EML metadata + data |
105 | 122 |
Map<Identifier, List<Identifier>> resources = new HashMap<Identifier, List<Identifier>>(); |
106 | 123 |
Identifier resourceMapPid = new Identifier(); |
107 | 124 |
resourceMapPid.setValue("resourceMap_" + metadataPid.getValue()); |
108 |
Identifier dataIdentifier = new Identifier(); |
|
109 |
dataIdentifier.setValue("derivedData.1.1"); |
|
110 | 125 |
List<Identifier> dataPids = Arrays.asList(dataIdentifier); |
111 | 126 |
resources.put(metadataPid, dataPids); |
112 | 127 |
|
Also available in: Unified diff
Create a derived data and metadata in the OrePackageTest