01: /*
02: * MCS Media Computer Software
03: * Copyright (c) 2005 by MCS
04: * --------------------------------------
05: * Created on 23.04.2005 by w.klaas
06: *
07: * Licensed under the Apache License, Version 2.0 (the "License");
08: * you may not use this file except in compliance with the License.
09: * You may obtain a copy of the License at
10: *
11: * http://www.apache.org/licenses/LICENSE-2.0
12: *
13: * Unless required by applicable law or agreed to in writing, software
14: * distributed under the License is distributed on an "AS IS" BASIS,
15: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16: * See the License for the specific language governing permissions and
17: * limitations under the License.
18: */
19: package de.mcs.jmeasurement.test;
20:
21: import junit.framework.TestCase;
22: import de.mcs.jmeasurement.MeasurementException;
23: import de.mcs.jmeasurement.Monitor;
24: import de.mcs.jmeasurement.NullMonitor;
25:
26: /**
27: * This class will test the functionality of the <code>NullMonitor</code>
28: * Object.
29: * @author w.klaas
30: */
31: public class NullMonitorTest extends TestCase {
32:
33: /** holding a private monitor */
34: private Monitor monitor;
35:
36: /** getting a monitor if don't exists */
37: private void init() {
38: if (null == monitor) {
39: monitor = new NullMonitor();
40: }
41: }
42:
43: public void testStart() throws InterruptedException,
44: MeasurementException {
45: init();
46: assertFalse(monitor.isRunning());
47: assertFalse(monitor.isPaused());
48: monitor.start();
49: Thread.sleep(1000);
50: monitor.stop();
51: assertEquals(0, monitor.getAccrued());
52: monitor.pause();
53: monitor.resume();
54: monitor.reset();
55: assertEquals(0, monitor.getAccrued());
56: monitor.increase(1000);
57: assertEquals(0, monitor.getAccrued());
58: monitor.decrease(500);
59: assertEquals(0, monitor.getAccrued());
60: assertEquals("", monitor.getMonitoId());
61: }
62: }
|