01: /*
02:
03: Copyright 2004, Martian Software, Inc.
04:
05: Licensed under the Apache License, Version 2.0 (the "License");
06: you may not use this file except in compliance with the License.
07: You may obtain a copy of the License at
08:
09: http://www.apache.org/licenses/LICENSE-2.0
10:
11: Unless required by applicable law or agreed to in writing, software
12: distributed under the License is distributed on an "AS IS" BASIS,
13: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: See the License for the specific language governing permissions and
15: limitations under the License.
16:
17: */
18:
19: package com.martiansoftware.nailgun;
20:
21: import junit.framework.TestCase;
22:
23: /**
24: *
25: * @author <a href="http://www.martiansoftware.com/contact.html">Marty Lamb</a>
26: */
27: public class TestNailStats extends TestCase {
28:
29: public void testNailStats() {
30: NailStats ns = new NailStats(TestNailStats.class);
31:
32: assertEquals(TestNailStats.class, ns.getNailClass());
33:
34: for (int i = 0; i < 1000; ++i) {
35: ns.nailStarted();
36: assertEquals(i + 1, ns.getRunCount());
37: assertEquals(1, ns.getRefCount());
38: ns.nailFinished();
39: }
40: assertEquals(1000, ns.getRunCount());
41: assertEquals(0, ns.getRefCount());
42:
43: NailStats ns2 = (NailStats) ns.clone();
44: assertEquals(ns, ns2);
45: assertEquals(ns.hashCode(), ns2.hashCode());
46:
47: assertEquals(
48: "com.martiansoftware.nailgun.TestNailStats: 1000/0", ns
49: .toString());
50: }
51: }
|