Project

General

Profile

Download (2.32 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.strategy.cache.media;
10

    
11
import java.net.URISyntaxException;
12

    
13
import org.junit.Assert;
14
import org.junit.Before;
15
import org.junit.BeforeClass;
16
import org.junit.Test;
17

    
18
import eu.etaxonomy.cdm.common.URI;
19
import eu.etaxonomy.cdm.model.common.Language;
20
import eu.etaxonomy.cdm.model.media.Media;
21
import eu.etaxonomy.cdm.model.media.MediaRepresentation;
22
import eu.etaxonomy.cdm.model.term.DefaultTermInitializer;
23

    
24
/**
25
 * @author a.mueller
26
 */
27
public class MediaDefaultCacheStrategyTest {
28

    
29
	@BeforeClass
30
	public static void setUpBeforeClass() throws Exception {
31
		new DefaultTermInitializer().initialize();
32
	}
33

    
34
	@Before
35
	public void setUp() throws Exception {
36
	}
37

    
38
//*********************** TESTS ****************************************************/
39

    
40
	@Test
41
	public void testGetTitleCache(){
42

    
43
		try {
44
			Media media = Media.NewInstance();
45
			media.putTitle(Language.DEFAULT(), "My best media");
46
			Assert.assertEquals("Wrong title cache for media", "My best media", media.getTitleCache());
47

    
48
			media = Media.NewInstance();
49
			Assert.assertTrue("Wrong title cache for media", media.getTitleCache().startsWith("- empty"));
50

    
51
			MediaRepresentation representation = MediaRepresentation.NewInstance(null, null, new URI("www.abc.de/myFileName.jpg"), 0, null);
52
			media.addRepresentation(representation);
53
			Assert.assertEquals("Wrong title cache for media", "myFileName.jpg", media.getTitleCache());
54
			media.removeRepresentation(representation);
55

    
56
			representation = MediaRepresentation.NewInstance(null, null, new URI("www.abc.de/"), 0, null);
57
			media.addRepresentation(representation);
58
			Assert.assertEquals("Wrong title cache for media", "www.abc.de/", media.getTitleCache());
59
		} catch (URISyntaxException e) {
60
			e.printStackTrace();
61
			Assert.fail("URI syntax exception");
62
		}
63
	}
64

    
65
	@Test
66
	public void testHandleEmptyUri(){
67
		Media media = Media.NewInstance();
68
		MediaRepresentation representation;
69
		representation = MediaRepresentation.NewInstance(null, null, null, 0, null);
70
		media.addRepresentation(representation);
71
	}
72
}
    (1-1/1)