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