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
|
|
10
|
package eu.etaxonomy.cdm.strategy.cache.media;
|
11
|
|
12
|
|
13
|
import java.net.URI;
|
14
|
import java.net.URISyntaxException;
|
15
|
|
16
|
import org.junit.Assert;
|
17
|
import org.junit.Before;
|
18
|
import org.junit.BeforeClass;
|
19
|
import org.junit.Test;
|
20
|
|
21
|
import eu.etaxonomy.cdm.model.common.DefaultTermInitializer;
|
22
|
import eu.etaxonomy.cdm.model.common.Language;
|
23
|
import eu.etaxonomy.cdm.model.description.TaxonDescription;
|
24
|
import eu.etaxonomy.cdm.model.media.Media;
|
25
|
import eu.etaxonomy.cdm.model.media.MediaRepresentation;
|
26
|
import eu.etaxonomy.cdm.model.name.BotanicalName;
|
27
|
import eu.etaxonomy.cdm.model.name.Rank;
|
28
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
29
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
30
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
31
|
|
32
|
/**
|
33
|
* @author a.mueller
|
34
|
*
|
35
|
*/
|
36
|
public class MediaDefaultCacheStrategyTest {
|
37
|
|
38
|
/**
|
39
|
* @throws java.lang.Exception
|
40
|
*/
|
41
|
@BeforeClass
|
42
|
public static void setUpBeforeClass() throws Exception {
|
43
|
new DefaultTermInitializer().initialize();
|
44
|
}
|
45
|
|
46
|
/**
|
47
|
* @throws java.lang.Exception
|
48
|
*/
|
49
|
@Before
|
50
|
public void setUp() throws Exception {
|
51
|
}
|
52
|
|
53
|
|
54
|
//*********************** TESTS ****************************************************/
|
55
|
|
56
|
@Test
|
57
|
public void testGetTitleCache(){
|
58
|
|
59
|
try {
|
60
|
Media media = Media.NewInstance();
|
61
|
media.putTitle(Language.DEFAULT(), "My best media");
|
62
|
Assert.assertEquals("Wrong title cache for media", "My best media", media.getTitleCache());
|
63
|
|
64
|
media = Media.NewInstance();
|
65
|
Assert.assertTrue("Wrong title cache for media", media.getTitleCache().startsWith("- empty"));
|
66
|
|
67
|
MediaRepresentation representation = MediaRepresentation.NewInstance(null, null, new URI("www.abc.de/myFileName.jpg"), 0);
|
68
|
media.addRepresentation(representation);
|
69
|
Assert.assertEquals("Wrong title cache for media", "myFileName.jpg", media.getTitleCache());
|
70
|
media.removeRepresentation(representation);
|
71
|
|
72
|
representation = MediaRepresentation.NewInstance(null, null, new URI("www.abc.de/"), 0);
|
73
|
media.addRepresentation(representation);
|
74
|
Assert.assertEquals("Wrong title cache for media", "www.abc.de/", media.getTitleCache());
|
75
|
} catch (URISyntaxException e) {
|
76
|
e.printStackTrace();
|
77
|
Assert.fail("URI syntax exception");
|
78
|
}
|
79
|
}
|
80
|
|
81
|
@Test
|
82
|
public void testHandleEmptyUri(){
|
83
|
Media media = Media.NewInstance();
|
84
|
MediaRepresentation representation;
|
85
|
representation = MediaRepresentation.NewInstance(null, null, null, 0);
|
86
|
media.addRepresentation(representation);
|
87
|
}
|
88
|
|
89
|
}
|