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.common.Language;
21  import eu.etaxonomy.cdm.model.common.LanguageString;
22  import eu.etaxonomy.cdm.model.media.Media;
23  
24  public class LanguageStringTest {
25  		
26  	    private String resource = "/eu/etaxonomy/cdm/io/jaxb/LanguageStringTest.xml";
27  	    
28  	    @Test
29  	    public void testUnmarshalLanguageString() 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 = (Media)dataSet.getMedia().get(0);	
35  			assertNotNull("Media must not be null",media);
36  			/* TODO: Does not work because the term loading does not work in test cases...
37  			assertNotNull("Media.title must not be null", media.getTitle(Language.ENGLISH()));
38  			assertFalse("Media.title must contain LanguageString elements",media.getAllTitles().isEmpty());
39  			LanguageString languageString = media.getAllTitles().values().iterator().next();
40  			assertNotNull("LanguageString.text must not be null", languageString.getText());
41  			assertEquals("LanguageString.text must contain the expected value","<i xmlns=\"http://www.w3.org/1999/xhtml\">English</i> Title",languageString.getText());
42  	   		*/
43  	    }
44  }