Project

General

Profile

« Previous | Next » 

Revision 4dbcb616

Added by Andreas Müller over 3 years ago

cleanup and use TermTestBase for model tests

View differences:

cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/media/MediaTest.java
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
9

  
10 9
package eu.etaxonomy.cdm.model.media;
11 10

  
12 11
import org.apache.log4j.Logger;
13
import org.junit.After;
14
import org.junit.AfterClass;
15 12
import org.junit.Assert;
16 13
import org.junit.Before;
17
import org.junit.BeforeClass;
18 14
import org.junit.Test;
19 15

  
20 16
import eu.etaxonomy.cdm.common.URI;
......
22 18
import eu.etaxonomy.cdm.model.common.Language;
23 19
import eu.etaxonomy.cdm.model.common.LanguageString;
24 20
import eu.etaxonomy.cdm.model.common.TimePeriod;
25
import eu.etaxonomy.cdm.model.term.DefaultTermInitializer;
21
import eu.etaxonomy.cdm.test.unit.EntityTestBase;
26 22

  
27 23
/**
28 24
 * @author a.mueller
29 25
 * @since 05.08.2009
30 26
 */
31
public class MediaTest {
27
public class MediaTest extends EntityTestBase {
28

  
32 29
    @SuppressWarnings("unused")
33 30
    private static final Logger logger = Logger.getLogger(MediaTest.class);
34 31

  
......
45 42
    private static URI uriString1;
46 43
    private static URI uriString2;
47 44

  
48
    /**
49
     * @throws java.lang.Exception
50
     */
51
    @BeforeClass
52
    public static void setUpBeforeClass() throws Exception {
53
        DefaultTermInitializer termInitializer = new DefaultTermInitializer();
54
        termInitializer.initialize();
45
    {
55 46
        try {
56 47
            uriString1 = new URI("http://Pathtoimage1/");
57 48
            uriString2 = new URI("http://Path_to_image_2/");
......
59 50
            e.printStackTrace();
60 51
            Assert.fail("Error in URI syntax");
61 52
        }
62

  
63
    }
64

  
65
    /**
66
     * @throws java.lang.Exception
67
     */
68
    @AfterClass
69
    public static void tearDownAfterClass() throws Exception {
70 53
    }
71 54

  
72
    /**
73
     * @throws java.lang.Exception
74
     */
75 55
    @Before
76 56
    public void setUp() throws Exception {
77 57
        media1 = Media.NewInstance();
......
105 85

  
106 86
    }
107 87

  
108
    /**
109
     * @throws java.lang.Exception
110
     */
111
    @After
112
    public void tearDown() throws Exception {
113
    }
114

  
115 88
//***************** TESTS *********************************/
116 89

  
117
    /**
118
     * Test method for {@link eu.etaxonomy.cdm.model.media.Media#clone()}.
119
     */
120 90
    @Test
121 91
    public void testClone() {
122 92
        try {
......
148 118

  
149 119
    }
150 120

  
151
    /**
152
     * Test method for {@link eu.etaxonomy.cdm.model.media.Media#addRepresentation(eu.etaxonomy.cdm.model.media.MediaRepresentation)}.
153
     */
154 121
    @Test
155 122
    public void testAddRepresentation() {
156 123
        Assert.assertTrue("Representations must contain mediaRepresentation1", media1.getRepresentations().contains(mediaRepresentation1));
157 124
    }
158 125

  
159
    /**
160
     * Test method for {@link eu.etaxonomy.cdm.model.media.Media#removeRepresentation(eu.etaxonomy.cdm.model.media.MediaRepresentation)}.
161
     */
162 126
    @Test
163 127
    public void testRemoveRepresentation() {
164 128
        Assert.assertTrue("Representations must contain mediaRepresentation1", media1.getRepresentations().contains(mediaRepresentation1));
......
170 134
        Assert.assertEquals("Number of representations must be 0", 0, media1.getRepresentations().size());
171 135
    }
172 136

  
173
    /**
174
     * Test method for {@link eu.etaxonomy.cdm.model.media.Media#addRights(eu.etaxonomy.cdm.model.media.Rights)}.
175
     */
176 137
    @Test
177 138
    public void testAddRights() {
178 139
        Assert.assertTrue("Rights must contain rights1", media1.getRights().contains(rights1));
179 140
    }
180 141

  
181
    /**
182
     * Test method for {@link eu.etaxonomy.cdm.model.media.Media#removeRights(eu.etaxonomy.cdm.model.media.Rights)}.
183
     */
184 142
    @Test
185 143
    public void testRemoveRights() {
186 144
        Assert.assertTrue("Rights must contain rights1", media1.getRights().contains(rights1));
......
189 147
        Assert.assertEquals("Number of rights must be 0", 0, media1.getRights().size());
190 148
    }
191 149

  
192
    /**
193
     * Test method for {@link eu.etaxonomy.cdm.model.media.Media#addTitle(eu.etaxonomy.cdm.model.common.LanguageString)}.
194
     */
195 150
    @Test
196 151
    public void testAddTitle() {
197 152
        Assert.assertSame("Title must be the same", languageString2, media1.getAllTitles().get(Language.DEFAULT()) );
198 153
    }
199 154

  
200
    /**
201
     * Test method for {@link eu.etaxonomy.cdm.model.media.Media#removeTitle(eu.etaxonomy.cdm.model.common.Language)}.
202
     */
203 155
    @Test
204 156
    public void testRemoveTitle() {
205 157
        Assert.assertSame("Title must be the same", languageString2, media1.getAllTitles().get(Language.DEFAULT()) );
......
210 162
        Assert.assertFalse("Title must not contain languageString2", languageString2.equals(media1.getAllTitles().get(Language.DEFAULT())));
211 163
    }
212 164

  
213
    /**
214
     * Test method for {@link eu.etaxonomy.cdm.model.media.Media#getMediaCreated()}.
215
     */
216 165
    @Test
217 166
    public void testGetMediaCreated() {
218 167
        Assert.assertEquals("Media created year must be 2002", "2002", media1.getMediaCreated().getYear());
219

  
220 168
    }
221 169

  
222
    /**
223
     * Test method for {@link eu.etaxonomy.cdm.model.media.Media#getDescription()}.
224
     */
225 170
    @Test
226 171
    public void testGetDescription() {
227 172
        Assert.assertTrue("Clone must have a default language description", media1.getAllDescriptions().containsKey(Language.DEFAULT()));
228 173
        Assert.assertSame("Description1 must be the same", languageString1, media1.getAllDescriptions().get(Language.DEFAULT()) );
229 174
    }
230 175

  
231
    /**
232
     * Test method for {@link eu.etaxonomy.cdm.model.media.Media#addDescription(eu.etaxonomy.cdm.model.common.LanguageString)}.
233
     */
234 176
    @Test
235 177
    public void testAddDescriptionLanguageString() {
236 178
        Assert.assertEquals("Number of descriptions must be 2", 2, media1.getAllDescriptions().size() );
......
241 183
        Assert.assertEquals("Default language description must be languageString2", languageString2, media1.getAllDescriptions().get(Language.DEFAULT()) );
242 184
    }
243 185

  
244
    /**
245
     * Test method for {@link eu.etaxonomy.cdm.model.media.Media#addDescription(java.lang.String, eu.etaxonomy.cdm.model.common.Language)}.
246
     */
247 186
    @Test
248 187
    public void testAddDescriptionStringLanguage() {
249 188
        Assert.assertTrue("Clone must have a german language description", media1.getAllDescriptions().containsKey(Language.GERMAN()));
......
255 194
        Assert.assertSame("Default language description must be 'testDesc2'", "testDesc2", media1.getAllDescriptions().get(Language.DEFAULT()).getText() );
256 195
    }
257 196

  
258
    /**
259
     * Test method for {@link eu.etaxonomy.cdm.model.media.Media#removeDescription(eu.etaxonomy.cdm.model.common.Language)}.
260
     */
261 197
    @Test
262 198
    public void testRemoveDescription() {
263 199
        Assert.assertEquals("Number of descriptions must be 2", 2, media1.getAllDescriptions().size() );
......
272 208
        media1.removeDescription(Language.GERMAN());
273 209
        Assert.assertEquals("Number of descriptions must be 0", 0, media1.getAllDescriptions().size() );
274 210
    }
275

  
276
}
211
}

Also available in: Unified diff