Lines Matching refs:Service
40 NoOpService service = new NoOpService();
41 Assert.assertEquals(Service.State.NEW, service.state());
42 assertFalse(service.isRunning());
43 assertFalse(service.running);
45 service.start();
46 assertEquals(Service.State.RUNNING, service.state());
47 assertTrue(service.isRunning());
48 assertTrue(service.running);
50 service.stop();
51 assertEquals(Service.State.TERMINATED, service.state());
52 assertFalse(service.isRunning());
53 assertFalse(service.running);
57 NoOpService service = new NoOpService();
59 service.start().get();
60 assertEquals(Service.State.RUNNING, service.state());
62 service.stop().get();
63 assertEquals(Service.State.TERMINATED, service.state());
67 NoOpService service = new NoOpService();
69 service.start();
70 service.start();
71 assertEquals(Service.State.RUNNING, service.state());
73 service.stop();
74 service.stop();
75 assertEquals(Service.State.TERMINATED, service.state());
79 NoOpService service = new NoOpService();
81 service.start().get();
82 service.start();
83 assertEquals(Service.State.RUNNING, service.state());
85 service.stop().get();
86 service.stop();
87 assertEquals(Service.State.TERMINATED, service.state());
91 NoOpService service = new NoOpService();
93 service.start().get();
94 service.start().get();
95 assertEquals(Service.State.RUNNING, service.state());
97 service.stop().get();
98 service.stop().get();
99 assertEquals(Service.State.TERMINATED, service.state());
104 NoOpService service = new NoOpService();
108 service.startAndWait();
109 assertEquals(Service.State.RUNNING, service.state());
111 service.stopAndWait();
112 assertEquals(Service.State.TERMINATED, service.state());
137 ManualSwitchedService service = new ManualSwitchedService();
139 service.start();
140 assertEquals(Service.State.STARTING, service.state());
141 assertFalse(service.isRunning());
142 assertTrue(service.doStartCalled);
144 service.notifyStarted(); // usually this would be invoked by another thread
145 assertEquals(Service.State.RUNNING, service.state());
146 assertTrue(service.isRunning());
148 service.stop();
149 assertEquals(Service.State.STOPPING, service.state());
150 assertFalse(service.isRunning());
151 assertTrue(service.doStopCalled);
153 service.notifyStopped(); // usually this would be invoked by another thread
154 assertEquals(Service.State.TERMINATED, service.state());
155 assertFalse(service.isRunning());
159 ManualSwitchedService service = new ManualSwitchedService();
161 service.start();
162 assertEquals(Service.State.STARTING, service.state());
163 assertFalse(service.isRunning());
164 assertTrue(service.doStartCalled);
166 service.stop();
167 assertEquals(Service.State.STOPPING, service.state());
168 assertFalse(service.isRunning());
169 assertFalse(service.doStopCalled);
171 service.notifyStarted();
172 assertEquals(Service.State.STOPPING, service.state());
173 assertFalse(service.isRunning());
174 assertTrue(service.doStopCalled);
176 service.notifyStopped();
177 assertEquals(Service.State.TERMINATED, service.state());
178 assertFalse(service.isRunning());
182 ManualSwitchedService service = new ManualSwitchedService();
184 service.start();
186 service.notifyStarted();
187 assertEquals(Service.State.RUNNING, service.state());
188 assertTrue(service.isRunning());
189 assertFalse(service.doStopCalled);
191 service.notifyStopped();
192 assertEquals(Service.State.TERMINATED, service.state());
193 assertFalse(service.isRunning());
194 assertFalse(service.doStopCalled);
198 * The user of this service should call {@link #notifyStarted} and {@link
217 ThreadedService service = new ThreadedService();
219 service.start().get();
220 assertEquals(Service.State.RUNNING, service.state());
222 service.awaitRunChecks();
224 service.stop().get();
225 assertEquals(Service.State.TERMINATED, service.state());
231 ThreadedService service = new ThreadedService();
233 service.start();
234 service.start().get();
235 assertEquals(Service.State.RUNNING, service.state());
237 service.awaitRunChecks();
239 service.stop();
240 service.stop().get();
241 assertEquals(Service.State.TERMINATED, service.state());
248 ThreadedService service = new ThreadedService();
250 service.start().get();
251 service.start();
252 assertEquals(Service.State.RUNNING, service.state());
254 service.awaitRunChecks();
256 service.stop().get();
257 service.stop();
258 assertEquals(Service.State.TERMINATED, service.state());
267 ThreadedService service = new ThreadedService();
269 service.start().get();
270 service.start().get();
271 assertEquals(Service.State.RUNNING, service.state());
273 service.awaitRunChecks();
275 service.stop().get();
276 service.stop().get();
277 assertEquals(Service.State.TERMINATED, service.state());
286 * The main test thread tries to stop() the service shortly after
287 * confirming that it is running. Meanwhile, the service itself is trying
290 * thread calls this method, which waits until the service has performed
294 assertTrue("Service thread hasn't finished its checks. "
341 NoOpService service = new NoOpService();
342 Future<Service.State> stopResult = service.stop();
343 assertEquals(Service.State.TERMINATED, service.state());
344 assertEquals(Service.State.TERMINATED, stopResult.get());
346 Future<Service.State> startResult = service.start();
347 assertEquals(Service.State.TERMINATED, service.state());
348 assertEquals(Service.State.TERMINATED, startResult.get());
352 StartThrowingService service = new StartThrowingService();
355 service.startAndWait();
363 StopThrowingService service = new StopThrowingService();
365 service.startAndWait();
367 service.stopAndWait();
375 RunThrowingService service = new RunThrowingService();
377 service.startAndWait();
379 service.stopAndWait();