1 | package com.ether; |
---|
2 | |
---|
3 | import com.medias.database.objects.Parametre; |
---|
4 | import com.medias.database.objects.Plateforme; |
---|
5 | import com.medias.database.objects.TypePlateforme; |
---|
6 | import com.medias.database.objects.Valeur; |
---|
7 | import org.apache.commons.logging.Log; |
---|
8 | import org.apache.commons.logging.LogFactory; |
---|
9 | |
---|
10 | public abstract class ServiceTestHelper<SERVICE extends Service> |
---|
11 | extends HibernateTestHelper<SERVICE> |
---|
12 | { |
---|
13 | protected ServiceTestHelper( final String serviceBeanName ) |
---|
14 | { |
---|
15 | super( null, serviceBeanName, getAllDependencies(), DEFAULT_SESSION_FACTORY_BEAN_NAME ); |
---|
16 | } |
---|
17 | |
---|
18 | protected void deleteAllKnownData() |
---|
19 | throws Exception |
---|
20 | { |
---|
21 | // deleteAllDatas( getAllKnownDomainClasses() ); |
---|
22 | } |
---|
23 | |
---|
24 | public static String[] getAllDependencies() |
---|
25 | { |
---|
26 | return new String[]{ |
---|
27 | "classpath:dao-context.xml", |
---|
28 | "classpath:service-context.xml", |
---|
29 | "classpath:hibernate_test.cfg.xml",}; |
---|
30 | } |
---|
31 | |
---|
32 | @SuppressWarnings("rawtypes") |
---|
33 | public static Class[] getAllKnownDomainClasses() |
---|
34 | { |
---|
35 | return new Class[]{ |
---|
36 | Plateforme.class, |
---|
37 | Parametre.class, |
---|
38 | Valeur.class,}; |
---|
39 | } |
---|
40 | |
---|
41 | /** |
---|
42 | * Executes operations before running test. |
---|
43 | */ |
---|
44 | protected abstract void beforeServiceTest() |
---|
45 | throws Exception; |
---|
46 | |
---|
47 | /** |
---|
48 | * Executes operations after running test. |
---|
49 | */ |
---|
50 | protected final void afterServiceTest() |
---|
51 | throws Exception |
---|
52 | { |
---|
53 | //deleteAllKnownData(); |
---|
54 | } |
---|
55 | |
---|
56 | protected final void beforeHibernateTest() |
---|
57 | throws Exception |
---|
58 | { |
---|
59 | beforeServiceTest(); |
---|
60 | } |
---|
61 | |
---|
62 | protected final void afterHibernateTest() |
---|
63 | throws Exception |
---|
64 | { |
---|
65 | afterServiceTest(); |
---|
66 | } |
---|
67 | |
---|
68 | protected final SERVICE getService() |
---|
69 | { |
---|
70 | return getBean(); |
---|
71 | } |
---|
72 | |
---|
73 | private static final Log LOGGER = LogFactory.getLog( ServiceTestHelper.class ); |
---|
74 | private static final String DEFAULT_SESSION_FACTORY_BEAN_NAME = "sessionFactory"; |
---|
75 | } |
---|