KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > test > MemoryLeakTestValidator


1 /*
2
3    Copyright 2003 The Apache Software Foundation
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 package org.apache.batik.test;
19
20 import org.apache.batik.test.TestReport;
21
22 /**
23  * One line Class Desc
24  *
25  * Complete Class Desc
26  *
27  * @author <a HREF="mailto:deweese@apache.org">l449433</a>
28  * @version $Id: MemoryLeakTestValidator.java,v 1.5 2005/03/27 08:58:37 cam Exp $
29  */

30 public class MemoryLeakTestValidator extends MemoryLeakTest {
31     public MemoryLeakTestValidator() {
32     }
33
34     Link start;
35     public TestReport doSomething() throws Exception JavaDoc {
36         for (int i=0; i<20; i++)
37             registerObjectDesc(new Object JavaDoc(), "Obj#"+i);
38         for (int i=0; i<10; i++) {
39             Pair p1 = new Pair();
40             Pair p2 = new Pair();
41             p1.mate(p2);
42             registerObjectDesc(p2, "Pair#"+i);
43         }
44         Link p = null;
45         for (int i=0; i<10; i++) {
46             p = new Link(p);
47             registerObjectDesc(p, "Link#"+i);
48         }
49         // Uncomment this to make the test fail with all the links.
50
// start = p;
51
return null;
52     }
53     
54     public static class Pair {
55         Pair myMate;
56         public Pair() { }
57         public void mate(Pair p) {
58             this.myMate = p;
59             p.myMate = this;
60         }
61     }
62
63     public static class Link {
64         public Link prev;
65         public Link(Link prev) {
66             this.prev = prev;
67         }
68     }
69
70 }
71
Popular Tags