View Javadoc

1   /**
2    * 
3    */
4   package net.sf.madmap;
5   
6   import java.util.ArrayList;
7   
8   import junit.framework.Test;
9   import junit.framework.TestCase;
10  import junit.framework.TestSuite;
11  
12  /**
13   * @author ecaspole
14   *
15   */
16  public class ObjectTest extends TestCase {
17  
18      /**
19       * Create the test case
20       *
21       * @param testName name of the test case
22       */	
23      public ObjectTest( String testName )
24      {
25          super( testName );
26      }
27  
28      /**
29       * @return the suite of tests being tested
30       */
31      public static Test suite()
32      {
33          return new TestSuite( ObjectTest.class );
34      }
35  
36      /**
37       * Rigourous Test :-)
38     		public HprofObject( long addr, String klass, long cls_addr, long size, int trace, ArrayList names, ArrayList objs ) {
39      */
40      public void testObject()
41      {
42      	String className = "fee.fi.fo.Fum";
43      	long objAddr = 0xffffffff;
44      	long clsAddr = 0xeeeeeeee;
45      	int trace = 1;
46      	long instanceSize = 32;
47      	String dataMemberName = "dataMember";
48      	ArrayList names = new ArrayList();
49      	Long dataMemberAddr = new Long( 0xdddddddd );
50      	ArrayList addrs = new ArrayList();
51      	
52      	names.add(dataMemberName);
53      	addrs.add( dataMemberAddr );
54      	HprofClassElement k = new HprofClassElement( clsAddr, className, instanceSize);
55        HprofObject ho = new HprofObject( objAddr, className, k, instanceSize, trace, names, addrs);
56      	ho.set_member_name_indexes( k.setNonstaticFieldNames( names ) );
57  
58        assertEquals( ho.className(), className );
59        assertEquals( ho.class_addr(), k );
60        assertEquals( ho.addr(), objAddr );
61        assertEquals( ho.size(), instanceSize );
62        assertEquals( ho.children_size(), addrs.size() );
63        assertNotNull( ho.children() );
64        assertNotNull(k.toString());
65        assertNotNull(ho.toString());
66      }
67  }