Revision 73baf7a4
Added by Andreas Müller almost 10 years ago
.gitattributes | ||
---|---|---|
1162 | 1162 |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/description/TaxonDescriptionDefaultCacheStrategyTest.java -text |
1163 | 1163 |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/media/MediaDefaultCacheStrategyTest.java -text |
1164 | 1164 |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/name/BotanicNameCacheStrategyTest.java -text |
1165 |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/name/NameCacheStrategyTestBase.java -text |
|
1165 | 1166 |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/name/NonViralNameDefaultCacheStrategyTest.java -text |
1166 | 1167 |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/name/ZooNameNoMarkerCacheStrategyTest.java -text |
1167 | 1168 |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/name/ZoologicalNameCacheStrategyTest.java -text |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/name/BotanicNameCacheStrategyTest.java | ||
---|---|---|
40 | 40 |
* @author a.mueller |
41 | 41 |
* |
42 | 42 |
*/ |
43 |
public class BotanicNameCacheStrategyTest { |
|
43 |
public class BotanicNameCacheStrategyTest extends NameCacheStrategyTestBase{
|
|
44 | 44 |
private static final Logger logger = Logger.getLogger(BotanicNameCacheStrategyTest.class); |
45 | 45 |
|
46 | 46 |
private static final String familyNameString = "Familia"; |
... | ... | |
276 | 276 |
} |
277 | 277 |
return method; |
278 | 278 |
} |
279 |
|
|
280 |
protected String getStringValue(Method method, Object object,Object parameter){ |
|
281 |
try { |
|
282 |
List<TaggedText> list = (List<TaggedText>)method.invoke(object, parameter); |
|
283 |
return NonViralNameDefaultCacheStrategy.createString(list); |
|
284 |
} catch (IllegalArgumentException e) { |
|
285 |
logger.error("IllegalArgumentException " + e.getMessage()); |
|
286 |
return null; |
|
287 |
} catch (IllegalAccessException e) { |
|
288 |
logger.error("IllegalAccessException " + e.getMessage()); |
|
289 |
return null; |
|
290 |
} catch (InvocationTargetException e) { |
|
291 |
logger.error("InvocationTargetException " + e.getMessage()); |
|
292 |
return null; |
|
293 |
} |
|
294 |
} |
|
279 |
|
|
295 | 280 |
|
296 | 281 |
|
297 | 282 |
} |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/name/NameCacheStrategyTestBase.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 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.name; |
|
10 |
|
|
11 |
import java.lang.reflect.InvocationTargetException; |
|
12 |
import java.lang.reflect.Method; |
|
13 |
import java.util.List; |
|
14 |
|
|
15 |
import org.apache.log4j.Logger; |
|
16 |
|
|
17 |
import eu.etaxonomy.cdm.strategy.cache.TaggedText; |
|
18 |
|
|
19 |
/** |
|
20 |
* Base class for testing name cache strategies |
|
21 |
* @author a.mueller |
|
22 |
*/ |
|
23 |
public class NameCacheStrategyTestBase { |
|
24 |
private static final Logger logger = Logger.getLogger(ZoologicalNameCacheStrategyTest.class); |
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
protected Method getMethod(Class<?> clazz, String methodName, Class<?> paramClazzes){ |
|
29 |
Method method; |
|
30 |
try { |
|
31 |
method = clazz.getDeclaredMethod(methodName, paramClazzes); |
|
32 |
} catch (SecurityException e) { |
|
33 |
logger.error("SecurityException " + e.getMessage()); |
|
34 |
return null; |
|
35 |
} catch (NoSuchMethodException e) { |
|
36 |
logger.error("NoSuchMethodException " + e.getMessage()); |
|
37 |
return null; |
|
38 |
} |
|
39 |
return method; |
|
40 |
} |
|
41 |
|
|
42 |
|
|
43 |
protected String getStringValue(Method method, Object object,Object parameter){ |
|
44 |
try { |
|
45 |
List<TaggedText> list = (List<TaggedText>)method.invoke(object, parameter); |
|
46 |
return NonViralNameDefaultCacheStrategy.createString(list); |
|
47 |
} catch (IllegalArgumentException e) { |
|
48 |
logger.error("IllegalArgumentException " + e.getMessage()); |
|
49 |
return null; |
|
50 |
} catch (IllegalAccessException e) { |
|
51 |
logger.error("IllegalAccessException " + e.getMessage()); |
|
52 |
return null; |
|
53 |
} catch (InvocationTargetException e) { |
|
54 |
logger.error("InvocationTargetException " + e.getMessage()); |
|
55 |
return null; |
|
56 |
} |
|
57 |
} |
|
58 |
} |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/name/NonViralNameDefaultCacheStrategyTest.java | ||
---|---|---|
41 | 41 |
* @author a.mueller |
42 | 42 |
* @created 26.11.2008 |
43 | 43 |
*/ |
44 |
public class NonViralNameDefaultCacheStrategyTest { |
|
44 |
public class NonViralNameDefaultCacheStrategyTest extends NameCacheStrategyTestBase{
|
|
45 | 45 |
@SuppressWarnings("unused") |
46 | 46 |
private static final Logger logger = Logger.getLogger(NonViralNameDefaultCacheStrategyTest.class); |
47 | 47 |
|
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/name/ZooNameNoMarkerCacheStrategyTest.java | ||
---|---|---|
10 | 10 |
package eu.etaxonomy.cdm.strategy.cache.name; |
11 | 11 |
|
12 | 12 |
import static org.junit.Assert.assertEquals; |
13 |
import static org.junit.Assert.assertNotNull; |
|
14 | 13 |
import static org.junit.Assert.assertNull; |
15 | 14 |
|
16 |
import java.lang.reflect.InvocationTargetException; |
|
17 | 15 |
import java.lang.reflect.Method; |
18 |
import java.util.List; |
|
19 | 16 |
|
20 | 17 |
import org.apache.log4j.Logger; |
21 | 18 |
import org.junit.Before; |
... | ... | |
28 | 25 |
import eu.etaxonomy.cdm.model.name.NonViralName; |
29 | 26 |
import eu.etaxonomy.cdm.model.name.Rank; |
30 | 27 |
import eu.etaxonomy.cdm.model.name.ZoologicalName; |
31 |
import eu.etaxonomy.cdm.strategy.cache.TaggedText; |
|
32 | 28 |
|
33 | 29 |
/** |
34 | 30 |
* @author a.mueller |
35 | 31 |
* |
36 | 32 |
*/ |
37 |
public class ZooNameNoMarkerCacheStrategyTest { |
|
33 |
public class ZooNameNoMarkerCacheStrategyTest extends NameCacheStrategyTestBase { |
|
34 |
@SuppressWarnings("unused") |
|
38 | 35 |
private static final Logger logger = Logger.getLogger(ZooNameNoMarkerCacheStrategyTest.class); |
39 | 36 |
|
40 | 37 |
private ZooNameDefaultCacheStrategy strategy; |
... | ... | |
191 | 188 |
String methodName = "getInfraGenusTaggedNameCache"; |
192 | 189 |
Method method = getMethod(NonViralNameDefaultCacheStrategy.class, methodName, NonViralName.class); |
193 | 190 |
|
194 |
this.getValue(method, strategy, subGenusName); |
|
191 |
this.getStringValue(method, strategy, subGenusName);
|
|
195 | 192 |
assertEquals("Genus (InfraGenericPart)", strategy.getNameCache(subGenusName)); |
196 | 193 |
} |
197 | 194 |
|
... | ... | |
225 | 222 |
assertEquals("Abies alba alba L.", strategy.getTitleCache(subSpeciesName)); |
226 | 223 |
} |
227 | 224 |
|
228 |
|
|
229 |
|
|
230 |
|
|
231 |
|
|
232 |
|
|
233 |
protected Method getMethod(Class clazz, String methodName, Class paramClazzes){ |
|
234 |
Method method; |
|
235 |
try { |
|
236 |
method = clazz.getDeclaredMethod(methodName, paramClazzes); |
|
237 |
} catch (SecurityException e) { |
|
238 |
logger.error("SecurityException " + e.getMessage()); |
|
239 |
return null; |
|
240 |
} catch (NoSuchMethodException e) { |
|
241 |
logger.error("NoSuchMethodException " + e.getMessage()); |
|
242 |
return null; |
|
243 |
} |
|
244 |
return method; |
|
245 |
} |
|
246 |
|
|
247 |
protected String getValue(Method method, Object object,Object parameter){ |
|
248 |
try { |
|
249 |
List<TaggedText> list = (List<TaggedText>)method.invoke(object, parameter); |
|
250 |
return NonViralNameDefaultCacheStrategy.createString(list); |
|
251 |
} catch (IllegalArgumentException e) { |
|
252 |
logger.error("IllegalArgumentException " + e.getMessage()); |
|
253 |
return null; |
|
254 |
} catch (IllegalAccessException e) { |
|
255 |
logger.error("IllegalAccessException " + e.getMessage()); |
|
256 |
return null; |
|
257 |
} catch (InvocationTargetException e) { |
|
258 |
logger.error("InvocationTargetException " + e.getMessage()); |
|
259 |
return null; |
|
260 |
} |
|
261 |
} |
|
262 |
|
|
263 | 225 |
|
264 | 226 |
} |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/name/ZoologicalNameCacheStrategyTest.java | ||
---|---|---|
13 | 13 |
import static org.junit.Assert.assertNotNull; |
14 | 14 |
import static org.junit.Assert.assertNull; |
15 | 15 |
|
16 |
import java.lang.reflect.InvocationTargetException; |
|
17 | 16 |
import java.lang.reflect.Method; |
18 |
import java.util.List; |
|
19 | 17 |
|
20 | 18 |
import org.apache.log4j.Logger; |
21 | 19 |
import org.junit.Before; |
... | ... | |
28 | 26 |
import eu.etaxonomy.cdm.model.name.NonViralName; |
29 | 27 |
import eu.etaxonomy.cdm.model.name.Rank; |
30 | 28 |
import eu.etaxonomy.cdm.model.name.ZoologicalName; |
31 |
import eu.etaxonomy.cdm.strategy.cache.TaggedText; |
|
32 | 29 |
|
33 | 30 |
/** |
34 | 31 |
* @author a.mueller |
35 | 32 |
* |
36 | 33 |
*/ |
37 |
public class ZoologicalNameCacheStrategyTest { |
|
34 |
public class ZoologicalNameCacheStrategyTest extends NameCacheStrategyTestBase { |
|
35 |
@SuppressWarnings("unused") |
|
38 | 36 |
private static final Logger logger = Logger.getLogger(ZoologicalNameCacheStrategyTest.class); |
39 | 37 |
|
40 | 38 |
private ZooNameDefaultCacheStrategy strategy; |
... | ... | |
199 | 197 |
String methodName = "getInfraGenusTaggedNameCache"; |
200 | 198 |
Method method = getMethod(NonViralNameDefaultCacheStrategy.class, methodName, NonViralName.class); |
201 | 199 |
|
202 |
this.getValue(method, strategy, subGenusName); |
|
200 |
this.getStringValue(method, strategy, subGenusName);
|
|
203 | 201 |
assertEquals("Genus subg. InfraGenericPart", strategy.getNameCache(subGenusName)); |
204 | 202 |
} |
205 | 203 |
|
... | ... | |
237 | 235 |
} |
238 | 236 |
|
239 | 237 |
|
240 |
|
|
241 |
|
|
242 |
|
|
243 |
|
|
244 |
protected Method getMethod(Class clazz, String methodName, Class paramClazzes){ |
|
245 |
Method method; |
|
246 |
try { |
|
247 |
method = clazz.getDeclaredMethod(methodName, paramClazzes); |
|
248 |
} catch (SecurityException e) { |
|
249 |
logger.error("SecurityException " + e.getMessage()); |
|
250 |
return null; |
|
251 |
} catch (NoSuchMethodException e) { |
|
252 |
logger.error("NoSuchMethodException " + e.getMessage()); |
|
253 |
return null; |
|
254 |
} |
|
255 |
return method; |
|
256 |
} |
|
257 |
|
|
258 |
protected String getValue(Method method, Object object,Object parameter){ |
|
259 |
try { |
|
260 |
List<TaggedText> list = (List<TaggedText>)method.invoke(object, parameter); |
|
261 |
return NonViralNameDefaultCacheStrategy.createString(list); |
|
262 |
} catch (IllegalArgumentException e) { |
|
263 |
logger.error("IllegalArgumentException " + e.getMessage()); |
|
264 |
return null; |
|
265 |
} catch (IllegalAccessException e) { |
|
266 |
logger.error("IllegalAccessException " + e.getMessage()); |
|
267 |
return null; |
|
268 |
} catch (InvocationTargetException e) { |
|
269 |
logger.error("InvocationTargetException " + e.getMessage()); |
|
270 |
return null; |
|
271 |
} |
|
272 |
} |
|
273 |
|
|
274 |
|
|
275 | 238 |
} |
Also available in: Unified diff
Cleaning up a bit