Project

General

Profile

Download (2.06 KB) Statistics
| Branch: | Tag: | Revision:
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 java.net.URI;
17

    
18
import org.junit.Test;
19

    
20
import eu.etaxonomy.cdm.model.description.Feature;
21
import eu.etaxonomy.cdm.model.description.FeatureNode;
22
import eu.etaxonomy.cdm.model.description.FeatureTree;
23

    
24
public class FeatureTest {
25
		
26
	    private String resource = "/eu/etaxonomy/cdm/io/jaxb/FeatureTest.xml";
27
	    
28
	    @Test
29
	    public void testUnmarshalFeatureTree() 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
			FeatureTree featureTree = (FeatureTree)dataSet.getFeatureTrees().get(0);
35
			Feature feature = (Feature)dataSet.getTerms().get(1);
36
			
37
			assertNotNull("FeatureTree must not be null",featureTree);
38
			assertNotNull("Feature must not be null",feature);
39
			
40
			assertNotNull("FeatureTree.root must not be null",featureTree.getRoot());
41
			FeatureNode featureNode = featureTree.getRoot();
42
			assertNotNull("FeatureNode.feature must not be null",featureNode.getFeature());
43
			assertEquals("FeatureNode.feature must equal Feature",feature,featureNode.getFeature());
44
			
45
			assertNotNull("FeatureNode.children must not be null",featureNode.getChildNodes());
46
			assertFalse("FeatureNode.children must not be empty",featureNode.getChildNodes().isEmpty());
47
			assertEquals("FeatureNode.children must have 4 child nodes",4,featureNode.getChildNodes().size());
48
			
49
	    }
50
}
(6-6/17)