KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > martiansoftware > nailgun > TestNailStats


1 /*
2
3   Copyright 2004, Martian Software, Inc.
4
5   Licensed under the Apache License, Version 2.0 (the "License");
6   you may not use this file except in compliance with the License.
7   You may obtain a copy of the License at
8
9   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("com.martiansoftware.nailgun.TestNailStats: 1000/0", ns.toString());
48     }
49 }
50
Popular Tags