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 de.mcs.jmeasurement.MeasureData;
22: import de.mcs.jmeasurement.MeasureFactory;
23: import de.mcs.jmeasurement.MeasurePoint;
24: import de.mcs.jmeasurement.MeasurementException;
25: import de.mcs.jmeasurement.Monitor;
26: import de.mcs.jmeasurement.example.IncrementTime100;
27:
28: /**
29: * @author w.klaas
30: */
31: public class IncrementTime100Test extends MCSTestCase {
32:
33: private static final String BASEPOINT = "de.mcs.jmeasurement.test";
34:
35: private static final String NOADDPOINT = "de.mcs.jmeasurement.noadd";
36:
37: public void testTime100() throws InterruptedException,
38: MeasurementException {
39: MeasureFactory.clear();
40: MeasureFactory.setPriority(0);
41: MeasureFactory.setEnable(true);
42: MeasureFactory.setMeasureDataCallback(new IncrementTime100());
43: MeasurePoint point1 = MeasureFactory.getMeasurePoint(BASEPOINT);
44: MeasurePoint point2 = MeasureFactory
45: .getMeasurePoint(NOADDPOINT);
46:
47: Monitor monitor1;
48: monitor1 = MeasureFactory.start(BASEPOINT);
49: Thread.sleep(100);
50: monitor1.stop();
51:
52: Monitor monitor2 = MeasureFactory.start(NOADDPOINT);
53: Thread.sleep(100);
54: monitor2.stop();
55:
56: MeasureData data1 = point1.getData("totalMSec");
57: MeasureData data2 = point2.getData("totalMSec");
58: // we allow precision of 10%
59: assertBetween(90, 110, ((Long) data1.getValue()).longValue()
60: - ((Long) data2.getValue()).longValue());
61:
62: System.out.println("----------");
63: System.out.println("testTime100");
64: System.out.println(MeasureFactory.asString());
65: }
66:
67: }
|