Project

General

Profile

Download (2.45 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.Test;
15

    
16
import eu.etaxonomy.cdm.common.URI;
17
import eu.etaxonomy.cdm.model.agent.Person;
18
import eu.etaxonomy.cdm.model.common.Language;
19
import eu.etaxonomy.cdm.model.media.Media;
20
import eu.etaxonomy.cdm.model.media.MediaRepresentation;
21
import eu.etaxonomy.cdm.test.TermTestBase;
22

    
23
/**
24
 * @author a.mueller
25
 */
26
public class MediaDefaultCacheStrategyTest extends TermTestBase {
27

    
28
//*********************** TESTS ****************************************************/
29

    
30
	@Test
31
	public void testGetTitleCache(){
32

    
33
		try {
34
			Media media = Media.NewInstance();
35
			media.putTitle(Language.DEFAULT(), "My best media");
36
			Assert.assertEquals("Wrong title cache for media", "My best media", media.getTitleCache());
37

    
38
			media = Media.NewInstance();
39
			Assert.assertTrue("Wrong title cache for empty media", media.getTitleCache().startsWith("- empty"));
40

    
41
			Person person = Person.NewTitledInstance("Artist");
42
			media.setArtist(person);
43
			Assert.assertEquals("Wrong title cache for media with artist", "Artist", media.getTitleCache());
44

    
45
			MediaRepresentation representation = MediaRepresentation.NewInstance(null, null, new URI("www.abc.de/myFileName"), 0, null);
46
			media.addRepresentation(representation);
47
			Assert.assertEquals("Wrong title cache for media with artist", "Artist", media.getTitleCache());
48

    
49
			media.setArtist(null);
50
			Assert.assertEquals("Wrong title cache for media", "myFileName", media.getTitleCache());
51
			media.removeRepresentation(representation);
52

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

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