1
|
/**
|
2
|
* Copyright (C) 2009 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.io.jaxb;
|
10
|
|
11
|
import static org.junit.Assert.assertEquals;
|
12
|
import static org.junit.Assert.assertFalse;
|
13
|
import static org.junit.Assert.assertNotNull;
|
14
|
|
15
|
import java.io.InputStreamReader;
|
16
|
import eu.etaxonomy.cdm.common.URI;
|
17
|
|
18
|
import org.junit.Test;
|
19
|
|
20
|
import eu.etaxonomy.cdm.model.media.Media;
|
21
|
import eu.etaxonomy.cdm.model.media.MediaRepresentation;
|
22
|
import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;
|
23
|
|
24
|
public class MediaTest {
|
25
|
|
26
|
private String resource = "/eu/etaxonomy/cdm/io/jaxb/MediaTest.xml";
|
27
|
|
28
|
@Test
|
29
|
public void testUnmarshalMedia() throws Exception {
|
30
|
CdmDocumentBuilder cdmDocumentBuilder = new CdmDocumentBuilder();
|
31
|
URI uri = new URI(URIEncoder.encode(this.getClass().getResource(resource).toString()));
|
32
|
DataSet dataSet = cdmDocumentBuilder.unmarshal(DataSet.class, new InputStreamReader(this.getClass().getResourceAsStream(resource)),uri.toString());
|
33
|
|
34
|
Media media = dataSet.getMedia().get(0);
|
35
|
assertNotNull("Media must not be null",media);
|
36
|
assertNotNull("Media.mediaRepresentations must not be null",media.getRepresentations());
|
37
|
assertFalse("Media.mediaRepresentations must not be empty",media.getRepresentations().isEmpty());
|
38
|
|
39
|
MediaRepresentation mediaRepresentation = media.getRepresentations().iterator().next();
|
40
|
assertEquals("Media must equal MediaRepresentation.media",media,mediaRepresentation.getMedia());
|
41
|
|
42
|
assertNotNull("MediaRepresentation.mediaRepresentationParts must not be null",mediaRepresentation.getParts());
|
43
|
assertFalse("MediaRepresentation.mediaRepresentationParts must not be empty",mediaRepresentation.getParts().isEmpty());
|
44
|
MediaRepresentationPart mediaRepresentationPart = mediaRepresentation.getParts().get(0);
|
45
|
assertEquals("MediaRepresentationPart.mediaRepresentation must equal MediaRepresentation",mediaRepresentation,mediaRepresentationPart.getMediaRepresentation());
|
46
|
}
|
47
|
}
|