1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.directory.server.core.integ;
20
21
22 import java.util.List;
23
24 import static org.apache.directory.server.core.integ.state.TestServiceContext.cleanup;
25 import static org.apache.directory.server.core.integ.state.TestServiceContext.destroy;
26 import static org.apache.directory.server.core.integ.state.TestServiceContext.shutdown;
27 import org.junit.internal.requests.IgnoredClassRunner;
28 import org.junit.internal.runners.InitializationError;
29 import org.junit.runner.Runner;
30 import org.junit.runner.notification.Failure;
31 import org.junit.runner.notification.RunNotifier;
32 import org.junit.runners.Suite;
33
34
35
36
37
38
39
40
41
42
43 public class CiSuite extends Suite
44 {
45 private InheritableSettings settings;
46
47
48 public CiSuite( Class<?> clazz ) throws InitializationError
49 {
50 super( clazz );
51 settings = new InheritableSettings( getDescription() );
52 }
53
54
55 public void addAll( List<? extends Runner> runners )
56 {
57 for ( Runner runner : getRunners() )
58 {
59 if ( runner instanceof CiRunner )
60 {
61 CiRunner cir = ( CiRunner) runner;
62 cir.setSuite( this );
63 }
64 else if ( runner instanceof IgnoredClassRunner )
65 {
66
67 }
68 else
69 {
70 throw new IllegalArgumentException( String.format( "Unexpected runner type \"%s\". " +
71 "Test classes within CiSuites must use CiRunners.", runner ) );
72 }
73 }
74
75 super.addAll( runners );
76 }
77
78
79 public void add( Runner runner )
80 {
81 if ( runner instanceof CiRunner )
82 {
83 CiRunner cir = ( CiRunner) runner;
84 cir.setSuite( this );
85 super.add( runner );
86 }
87 else if ( runner instanceof IgnoredClassRunner )
88 {
89
90 }
91 else
92 {
93 throw new IllegalArgumentException( String.format( "Unexpected runner type \"%s\". " +
94 "Test classes within CiSuites must use CiRunners.", runner ) );
95 }
96 }
97
98
99 @Override
100 public void run( final RunNotifier notifier )
101 {
102 super.run( notifier );
103
104
105
106
107
108
109
110
111
112
113
114
115 if ( settings.getCleanupLevel() != Level.SYSTEM )
116 {
117 try
118 {
119 shutdown();
120 cleanup();
121 destroy();
122 }
123 catch ( Exception e )
124 {
125 notifier.fireTestFailure( new Failure( getDescription(), e ) );
126 }
127 }
128 }
129
130
131 public InheritableSettings getSettings()
132 {
133 return settings;
134 }
135 }