incubator-kato-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From monte...@apache.org
Subject svn commit: r774797 - in /incubator/kato/trunk/KatoHProfAdapterPOC: src/org/apache/kato/hprof/image/ src/org/apache/kato/hprof/java/ testsrc/org/apache/kato/hprof/java/ testsrc/test/apache/kato/hprof/ testsrc/test/apache/kato/hprof/image/
Date Thu, 14 May 2009 14:48:50 GMT
Author: monteith
Date: Thu May 14 14:48:49 2009
New Revision: 774797

URL: http://svn.apache.org/viewvc?rev=774797&view=rev
Log:
Finish adding tests to the image API. Also fixup ImagePointer to return address space.

Added:
    incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImagePointer.java
  (with props)
Modified:
    incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageAddressSpaceImpl.java
    incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageImpl.java
    incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImagePointerImpl.java
    incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageProcessImpl.java
    incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/IJavaHeapInternal.java
    incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaClassImpl.java
    incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaClassLoaderImpl.java
    incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaHeapImpl.java
    incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaObjectArrayImpl.java
    incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaObjectInstanceImpl.java
    incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaPrimitiveArrayImpl.java
    incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaPrimitiveClassImpl.java
    incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaRuntimeImpl.java
    incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaStackFrameImpl.java
    incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaThreadImpl.java
    incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/org/apache/kato/hprof/java/JavaHeapImplTest.java
    incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/org/apache/kato/hprof/java/JavaPrimitiveClassImplTest.java
    incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/TestJavaHeap.java
    incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImageAddressSpace.java
    incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImageProcess.java

Modified: incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageAddressSpaceImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageAddressSpaceImpl.java?rev=774797&r1=774796&r2=774797&view=diff
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageAddressSpaceImpl.java
(original)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageAddressSpaceImpl.java
Thu May 14 14:48:49 2009
@@ -54,7 +54,7 @@
 
 	@Override
 	public ImagePointer getPointer(long address) {		
-		return new ImagePointerImpl(address);
+		return new ImagePointerImpl(address, this);
 	}
 
 	@Override

Modified: incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageImpl.java?rev=774797&r1=774796&r2=774797&view=diff
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageImpl.java
(original)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageImpl.java
Thu May 14 14:48:49 2009
@@ -25,19 +25,16 @@
 public class ImageImpl implements Image {
 
 	HProfFile file=null;
-	
+	List addressSpaces = new LinkedList();
 	
 	public ImageImpl(HProfFile file) {
 		if(file==null) throw new IllegalArgumentException("file is null");
 		this.file=file;
-		
+		addressSpaces.add(new ImageAddressSpaceImpl(this));
 	}
 	@Override
-	public Iterator getAddressSpaces() {
-		List list=new LinkedList();
-		list.add(new ImageAddressSpaceImpl(this));
-		
-		return list.iterator();
+	public Iterator getAddressSpaces() {		
+		return addressSpaces.iterator();
 	}
 
 	@Override

Modified: incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImagePointerImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImagePointerImpl.java?rev=774797&r1=774796&r2=774797&view=diff
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImagePointerImpl.java
(original)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImagePointerImpl.java
Thu May 14 14:48:49 2009
@@ -20,16 +20,16 @@
 import org.apache.kato.image.MemoryAccessException;
 
 public class ImagePointerImpl implements ImagePointer {
-	
 	private long address=0;
+	private ImageAddressSpace addressSpace;
 	
-	public ImagePointerImpl(long address) {
+	public ImagePointerImpl(long address, ImageAddressSpace addressSpace) {
 		this.address=address;
+		this.addressSpace = addressSpace;
 	}
 	@Override
-	public ImagePointer add(long offset) {
-		
-		return new ImagePointerImpl(address+offset);
+	public ImagePointer add(long offset) {		
+		return new ImagePointerImpl(address+offset, addressSpace);
 	}
 
 	@Override
@@ -39,9 +39,8 @@
 	}
 
 	@Override
-	public ImageAddressSpace getAddressSpace() {
-		
-		return null;
+	public ImageAddressSpace getAddressSpace() {		
+		return addressSpace;
 	}
 
 	@Override
@@ -83,8 +82,8 @@
 	@Override
 	public ImagePointer getPointerAt(long index) throws MemoryAccessException,
 			CorruptDataException {
-		
-		return new ImagePointerImpl(index);
+		throwError();
+		return null;
 	}
 
 	@Override
@@ -114,4 +113,31 @@
 		throw new MemoryAccessException(this,"memory access invalid with hprof dump");
 	}
 
+	/**
+	 * Is this a good hashcode?
+	 */
+	@Override
+	public int hashCode() {
+		return (int) ( address % Integer.MAX_VALUE );
+	}
+	
+	/**
+	 * This is the same ImagePointer if the addresses are the same in the same addresspace.
+	 */
+	@Override
+	public boolean equals(Object obj) {
+		if ( obj == null){
+			return false;
+		} else if (!(obj instanceof ImagePointerImpl)) {
+			return false;
+		} 
+		
+		ImageAddressSpace otherAddressSpace = ((ImagePointerImpl) obj).getAddressSpace();
+		
+		if (otherAddressSpace.equals(getAddressSpace())) {
+			return address == ((ImagePointerImpl)obj).getAddress();
+		}
+		
+		return false;		
+	}
 }

Modified: incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageProcessImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageProcessImpl.java?rev=774797&r1=774796&r2=774797&view=diff
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageProcessImpl.java
(original)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/image/ImageProcessImpl.java
Thu May 14 14:48:49 2009
@@ -24,6 +24,7 @@
 import org.apache.kato.hprof.java.JavaRuntimeImpl;
 import org.apache.kato.image.CorruptDataException;
 import org.apache.kato.image.DataUnavailable;
+import org.apache.kato.image.ImageAddressSpace;
 import org.apache.kato.image.ImageModule;
 import org.apache.kato.image.ImageProcess;
 import org.apache.kato.image.ImageThread;
@@ -99,7 +100,7 @@
 	public Iterator getRuntimes() {
 		
 		if(javaRuntime==null) {
-			javaRuntime=new JavaRuntimeImpl(this.view); 
+			javaRuntime=new JavaRuntimeImpl(this.view, (ImageAddressSpace) imageImpl.getAddressSpaces().next());

 		}
 		List list=new LinkedList();
 		list.add(javaRuntime);

Modified: incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/IJavaHeapInternal.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/IJavaHeapInternal.java?rev=774797&r1=774796&r2=774797&view=diff
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/IJavaHeapInternal.java
(original)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/IJavaHeapInternal.java
Thu May 14 14:48:49 2009
@@ -15,6 +15,7 @@
 
 import java.util.Collection;
 
+import org.apache.kato.image.ImagePointer;
 import org.apache.kato.java.JavaHeap;
 import org.apache.kato.java.JavaObject;
 
@@ -38,7 +39,7 @@
 
 	abstract JavaPrimitiveClassImpl getPrimitiveClass(int l);
 
-	Collection<JavaClassLoaderImpl> getJavaClassLoaders();
-
+	abstract Collection<JavaClassLoaderImpl> getJavaClassLoaders();
 
+	abstract ImagePointer getImagePointer(long address); 
 }

Modified: incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaClassImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaClassImpl.java?rev=774797&r1=774796&r2=774797&view=diff
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaClassImpl.java
(original)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaClassImpl.java
Thu May 14 14:48:49 2009
@@ -568,7 +568,7 @@
 	 */
 	@Override	
 	public ImagePointer getID() {
-		return new ImagePointerImpl(javaClass.getClassObjectID());
+		return heap.getImagePointer(javaClass.getClassObjectID());
 	}
 
 	/**

Modified: incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaClassLoaderImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaClassLoaderImpl.java?rev=774797&r1=774796&r2=774797&view=diff
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaClassLoaderImpl.java
(original)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaClassLoaderImpl.java
Thu May 14 14:48:49 2009
@@ -104,7 +104,7 @@
 			JavaClassImpl clazz = heap.getJavaClassByID(ID);
 
 			if (clazz == null) {
-				return new CorruptDataImpl(new ImagePointerImpl(ID), "Can't match class object ID to
a JavaClassImpl.");
+				return new CorruptDataImpl(heap.getImagePointer(ID), "Can't match class object ID to
a JavaClassImpl.");
 			}
 			
 			return clazz;

Modified: incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaHeapImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaHeapImpl.java?rev=774797&r1=774796&r2=774797&view=diff
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaHeapImpl.java
(original)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaHeapImpl.java
Thu May 14 14:48:49 2009
@@ -32,6 +32,8 @@
 import org.apache.kato.hprof.datalayer.IHProfRecord;
 import org.apache.kato.hprof.datalayer.IHeapDumpHProfRecord;
 import org.apache.kato.hprof.datalayer.IHeapObject;
+import org.apache.kato.image.ImageAddressSpace;
+import org.apache.kato.image.ImagePointer;
 import org.apache.kato.java.JavaObject;
 
 
@@ -44,11 +46,13 @@
 public class JavaHeapImpl implements IJavaHeapInternal {
 	private HProfView view=null;
 	long  heapRecordId=0;
+	private ImageAddressSpace addressSpace;
 	
-	public JavaHeapImpl(HProfView view,long loc) {
+	public JavaHeapImpl(HProfView view,long loc, ImageAddressSpace addressSpace) {
 		if(loc<1) throw new IllegalArgumentException("heap record id ["+loc+"] is less than
1");
 		this.view=view;
 		this.heapRecordId=loc;
+		this.addressSpace = addressSpace;
 	}
 	
 	@Override
@@ -251,7 +255,7 @@
 					 name ="<invalid primitive class type "+type+">";
 			}
 			
-			clazz = primitiveClasses[type-4] = new JavaPrimitiveClassImpl(name, type,
+			clazz = primitiveClasses[type-4] = new JavaPrimitiveClassImpl(name, getImagePointer(type),
 					this.getJavaClassLoaderByID(0)); // The system class loader is 0
 		}
 		
@@ -304,5 +308,10 @@
 	public String getUTF8StringByID(long ID) {
 		return view.getUTF8String(ID);
 	}
+
+	@Override
+	public ImagePointer getImagePointer(long address) {
+		return addressSpace.getPointer(address);
+	}
 	
 }

Modified: incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaObjectArrayImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaObjectArrayImpl.java?rev=774797&r1=774796&r2=774797&view=diff
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaObjectArrayImpl.java
(original)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaObjectArrayImpl.java
Thu May 14 14:48:49 2009
@@ -101,7 +101,7 @@
 
 	@Override
 	public ImagePointer getID() {
-		return new ImagePointerImpl(record.getID());
+		return heap.getImagePointer(record.getID());
 	}
 
 	@Override

Modified: incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaObjectInstanceImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaObjectInstanceImpl.java?rev=774797&r1=774796&r2=774797&view=diff
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaObjectInstanceImpl.java
(original)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaObjectInstanceImpl.java
Thu May 14 14:48:49 2009
@@ -65,7 +65,7 @@
 
 	@Override
 	public ImagePointer getID() {		
-		return new ImagePointerImpl(record.getID());
+		return heap.getImagePointer(record.getID());
 	}
 
 	@Override

Modified: incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaPrimitiveArrayImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaPrimitiveArrayImpl.java?rev=774797&r1=774796&r2=774797&view=diff
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaPrimitiveArrayImpl.java
(original)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaPrimitiveArrayImpl.java
Thu May 14 14:48:49 2009
@@ -191,7 +191,7 @@
 
 	@Override
 	public ImagePointer getID() {
-		return new ImagePointerImpl(record.getID());
+		return heap.getImagePointer(record.getID());
 	}
 
 	@Override

Modified: incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaPrimitiveClassImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaPrimitiveClassImpl.java?rev=774797&r1=774796&r2=774797&view=diff
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaPrimitiveClassImpl.java
(original)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaPrimitiveClassImpl.java
Thu May 14 14:48:49 2009
@@ -31,10 +31,10 @@
  */
 public class JavaPrimitiveClassImpl implements JavaClass {
 	private String name;
-	private int id;
+	private ImagePointer id;
 	private JavaClassLoader loader;
 	
-	public JavaPrimitiveClassImpl(String name, int id, JavaClassLoader loader) {
+	public JavaPrimitiveClassImpl(String name, ImagePointer id, JavaClassLoader loader) {
 		this.name = name;
 		this.id = id;
 		this.loader = loader;
@@ -69,7 +69,7 @@
 	@Override
 	public ImagePointer getID() {
 		// Use basic type id as the id.
-		return new ImagePointerImpl(id);
+		return id;
 	}
 
 	@Override

Modified: incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaRuntimeImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaRuntimeImpl.java?rev=774797&r1=774796&r2=774797&view=diff
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaRuntimeImpl.java
(original)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaRuntimeImpl.java
Thu May 14 14:48:49 2009
@@ -13,19 +13,17 @@
  ******************************************************************************/
 package org.apache.kato.hprof.java;
 
-import java.io.IOException;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 
-import org.apache.kato.common.IViewMonitor;
 import org.apache.kato.hprof.HProfView;
 import org.apache.kato.hprof.IJavaThread;
-import org.apache.kato.hprof.datalayer.HProfFile;
 import org.apache.kato.hprof.image.CorruptDataImpl;
 import org.apache.kato.image.CorruptDataException;
 import org.apache.kato.image.DataUnavailable;
+import org.apache.kato.image.ImageAddressSpace;
 import org.apache.kato.image.ImagePointer;
 import org.apache.kato.image.MemoryAccessException;
 import org.apache.kato.java.JavaHeap;
@@ -36,9 +34,9 @@
 public class JavaRuntimeImpl implements JavaRuntime {
 
 	private HProfView view=null;
-	public JavaRuntimeImpl(HProfView view) {
+	public JavaRuntimeImpl(HProfView view, ImageAddressSpace addressSpace) {
 		this.view = view;
-		heap = new JavaHeapImpl(view, view.getHeapRecordLocation());
+		heap = new JavaHeapImpl(view, view.getHeapRecordLocation(), addressSpace);
 	}
 
 	/**

Modified: incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaStackFrameImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaStackFrameImpl.java?rev=774797&r1=774796&r2=774797&view=diff
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaStackFrameImpl.java
(original)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaStackFrameImpl.java
Thu May 14 14:48:49 2009
@@ -35,7 +35,7 @@
 	 */
 	@Override
 	public ImagePointer getBasePointer() throws CorruptDataException {		
-		return new ImagePointerImpl(frame.getID());
+		return heap.getImagePointer(frame.getID());
 	}
 
 	@Override
@@ -69,7 +69,7 @@
 		
 		@Override
 		public ImagePointer getAddress() throws CorruptDataException {
-			return new ImagePointerImpl(frame.getID());
+			return heap.getImagePointer(frame.getID());
 		}
 
 		

Modified: incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaThreadImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaThreadImpl.java?rev=774797&r1=774796&r2=774797&view=diff
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaThreadImpl.java
(original)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/src/org/apache/kato/hprof/java/JavaThreadImpl.java
Thu May 14 14:48:49 2009
@@ -49,7 +49,7 @@
 	 */
 	@Override
 	public ImagePointer getJNIEnv() throws CorruptDataException {
-		return new ImagePointerImpl(thread.getThreadSerialNumber());
+		return heap.getImagePointer(thread.getThreadSerialNumber());
 	}
 
 	@Override

Modified: incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/org/apache/kato/hprof/java/JavaHeapImplTest.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/org/apache/kato/hprof/java/JavaHeapImplTest.java?rev=774797&r1=774796&r2=774797&view=diff
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/org/apache/kato/hprof/java/JavaHeapImplTest.java
(original)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/org/apache/kato/hprof/java/JavaHeapImplTest.java
Thu May 14 14:48:49 2009
@@ -17,6 +17,8 @@
 import java.util.HashMap;
 import java.util.Iterator;
 
+import org.apache.kato.hprof.image.ImagePointerImpl;
+import org.apache.kato.image.ImagePointer;
 import org.apache.kato.java.JavaObject;
 
 /**
@@ -93,5 +95,9 @@
 		// TODO Auto-generated method stub
 		return null;
 	}
+	@Override
+	public ImagePointer getImagePointer(long address) {
+		return new ImagePointerImpl(address, null);
+	}
 
 }

Modified: incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/org/apache/kato/hprof/java/JavaPrimitiveClassImplTest.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/org/apache/kato/hprof/java/JavaPrimitiveClassImplTest.java?rev=774797&r1=774796&r2=774797&view=diff
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/org/apache/kato/hprof/java/JavaPrimitiveClassImplTest.java
(original)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/org/apache/kato/hprof/java/JavaPrimitiveClassImplTest.java
Thu May 14 14:48:49 2009
@@ -17,6 +17,7 @@
 
 import junit.framework.TestCase;
 
+import org.apache.kato.hprof.image.ImagePointerImpl;
 import org.apache.kato.java.JavaClass;
 
 /**
@@ -29,7 +30,7 @@
 	static int id = 10;
 	
 	public void setUp() {
-		instance = new JavaPrimitiveClassImpl(className,id , null);
+		instance = new JavaPrimitiveClassImpl(className, new ImagePointerImpl(id,null) , null);
 	}
 	
 	public void testName() throws Exception {

Modified: incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/TestJavaHeap.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/TestJavaHeap.java?rev=774797&r1=774796&r2=774797&view=diff
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/TestJavaHeap.java
(original)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/TestJavaHeap.java
Thu May 14 14:48:49 2009
@@ -25,7 +25,7 @@
 	public void testNullConstructor() {
 		
 		try {
-		JavaHeapImpl impl=new JavaHeapImpl(null,0);
+		JavaHeapImpl impl=new JavaHeapImpl(null,0, null);
 		fail("expected illegal argument exception");
 		}
 		catch(IllegalArgumentException iae) {
@@ -38,7 +38,7 @@
 		HProfView view=getMinimalHProfView();
 		
 		try {
-		JavaHeapImpl impl=new JavaHeapImpl(view,0);
+		JavaHeapImpl impl=new JavaHeapImpl(view,0, null);
 		fail("expected illegal argument exception");
 		}
 		catch(IllegalArgumentException iae) {

Modified: incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImageAddressSpace.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImageAddressSpace.java?rev=774797&r1=774796&r2=774797&view=diff
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImageAddressSpace.java
(original)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImageAddressSpace.java
Thu May 14 14:48:49 2009
@@ -17,6 +17,7 @@
 import java.util.Iterator;
 
 import org.apache.kato.image.ImageAddressSpace;
+import org.apache.kato.image.ImagePointer;
 import org.apache.kato.image.ImageProcess;
 
 public class TestImageAddressSpace extends AbstractHProfTestCase {
@@ -70,4 +71,34 @@
 		ImageProcess current=space.getCurrentProcess();
 		assertEquals("first image process is not current",current,p);
 	}
+	
+	public void testEqualsEquals() throws Exception {
+		ImageAddressSpace space=getFirstAddressSpace();
+		
+		assertTrue(space.equals(space));
+	}
+	
+	public void testNotEqualsNull() throws Exception {
+		ImageAddressSpace space=getFirstAddressSpace();
+		
+		assertFalse(space.equals(null));
+	}
+	
+	public void testNotEqualsString() throws Exception {
+		ImageAddressSpace space=getFirstAddressSpace();
+		
+		assertFalse(space.equals("String"));
+	}
+	
+	public void testGetPointerZero() throws Exception {
+		ImagePointer pointer = getFirstAddressSpace().getPointer(0);
+		
+		assertEquals(0, pointer.getAddress());
+	}
+	
+	public void testGetPointerNonZero() throws Exception {
+		ImagePointer pointer = getFirstAddressSpace().getPointer(0xfefeededdcdccbcbL);
+		
+		assertEquals(0xfefeededdcdccbcbL, pointer.getAddress());
+	}
 }

Added: incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImagePointer.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImagePointer.java?rev=774797&view=auto
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImagePointer.java
(added)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImagePointer.java
Thu May 14 14:48:49 2009
@@ -0,0 +1,169 @@
+package test.apache.kato.hprof.image;
+
+import java.io.IOException;
+
+import org.apache.kato.image.CorruptDataException;
+import org.apache.kato.image.DataUnavailable;
+import org.apache.kato.image.ImageAddressSpace;
+import org.apache.kato.image.ImagePointer;
+import org.apache.kato.image.MemoryAccessException;
+
+public class TestImagePointer extends AbstractHProfTestCase {
+
+	ImageAddressSpace space;
+	ImagePointer pointer1;
+	static final long address1 = 0xfefeededdcdccbcbL;
+	
+	public void setUp() throws IOException {
+		space = getFirstAddressSpace();
+		pointer1 = space.getPointer(address1);
+	}
+	
+	public void testGetAddress() throws Exception {
+		assertEquals(address1, pointer1.getAddress());
+	}
+	
+	public void testAdd() throws Exception {
+		ImagePointer pointer2 = pointer1.add(7);
+		
+		assertEquals(address1+7, pointer2.getAddress());
+	}
+	
+	public void testIsExecutable() throws Exception {
+		try {			
+			pointer1.isExecutable();
+			fail("DataUnavailable should be thrown.");
+		} catch (DataUnavailable e) {
+			// Expected
+		}
+	}
+	
+	public void testIsReadOnly() throws Exception {
+		try {
+			pointer1.isReadOnly();
+			fail("DataUnavailable should be thrown.");
+		} catch (DataUnavailable e) {
+			// Expected
+		}
+	}
+	public void testIsShared() throws Exception {
+		try {			
+			pointer1.isShared();
+			fail("DataUnavailable should be thrown.");
+		} catch (DataUnavailable e) {
+			// Expected
+		}
+	}
+	
+	public void testGetAddressSpace() throws Exception {
+		assertEquals(space, pointer1.getAddressSpace());
+	}
+	
+	public void testGetByteAt() throws Exception {
+		try {
+			pointer1.getByteAt(0);
+			fail("Expected MemoryAccessException");
+		} catch (MemoryAccessException e) {
+			// expected
+		} catch (CorruptDataException e) {
+			fail("Expected MemoryAccessException");
+		}
+	}
+	
+	public void testGetDoubleAt() throws Exception {
+		try {
+			pointer1.getDoubleAt(0);
+			fail("Expected MemoryAccessException");
+		} catch (MemoryAccessException e) {
+			// expected
+		} catch (CorruptDataException e) {
+			fail("Expected MemoryAccessException");
+		}
+	}
+	
+	public void testGetFloatAt() throws Exception {
+		try {
+			pointer1.getFloatAt(0);
+			fail("Expected MemoryAccessException");
+		} catch (MemoryAccessException e) {
+			// expected
+		} catch (CorruptDataException e) {
+			fail("Expected MemoryAccessException");
+		}
+	}
+	
+	public void testGetIntAt() throws Exception {
+		try {
+			pointer1.getIntAt(0);
+			fail("Expected MemoryAccessException");
+		} catch (MemoryAccessException e) {
+			// expected
+		} catch (CorruptDataException e) {
+			fail("Expected MemoryAccessException");
+		}
+	}
+	
+	public void testGetLongAt() throws Exception {
+		try {
+			pointer1.getLongAt(0);
+			fail("Expected MemoryAccessException");
+		} catch (MemoryAccessException e) {
+			// expected
+		} catch (CorruptDataException e) {
+			fail("Expected MemoryAccessException");
+		}
+	}
+	
+	public void testGetShortAt() throws Exception {
+		try {
+			pointer1.getShortAt(0);
+			fail("Expected MemoryAccessException");
+		} catch (MemoryAccessException e) {
+			// expected
+		} catch (CorruptDataException e) {
+			fail("Expected MemoryAccessException");
+		}
+	}
+
+	public void testGetPointerAt() throws Exception {
+		try {
+			pointer1.getPointerAt(0);
+			fail("Expected MemoryAccessException");
+		} catch (MemoryAccessException e) {
+			// expected
+		} catch (CorruptDataException e) {
+			fail("Expected MemoryAccessException");
+		}
+	}
+	
+	public void testEqualsNull() throws Exception {
+		assertFalse(pointer1.equals(null));
+	}
+	
+	public void testEqualsString() throws Exception {
+		assertFalse(pointer1.equals("Hello"));
+	}
+	
+	public void testEqualsSelf() throws Exception {
+		assertTrue(pointer1.equals(pointer1));		
+	}
+	
+	public void testEqualsLike() throws Exception {
+		ImagePointer pointer2 = space.getPointer(address1);
+		
+		assertTrue(pointer1.equals(pointer2));
+	}
+	
+	public void testEqualsDifferent() throws Exception {
+		ImagePointer pointer2 = space.getPointer(0x2983474);
+		
+		assertFalse(pointer1.equals(pointer2));
+	}
+	
+	public void testHashCode() throws Exception {
+		ImagePointer pointer2 = space.getPointer(address1);
+		assertEquals(pointer1.hashCode(), pointer2.hashCode());
+	}
+	
+	
+}

Propchange: incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImagePointer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImageProcess.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImageProcess.java?rev=774797&r1=774796&r2=774797&view=diff
==============================================================================
--- incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImageProcess.java
(original)
+++ incubator/kato/trunk/KatoHProfAdapterPOC/testsrc/test/apache/kato/hprof/image/TestImageProcess.java
Thu May 14 14:48:49 2009
@@ -14,108 +14,173 @@
 package test.apache.kato.hprof.image;
 
 import java.io.IOException;
+import java.util.Iterator;
 
 import org.apache.kato.image.CorruptDataException;
 import org.apache.kato.image.DataUnavailable;
+import org.apache.kato.image.ImageAddressSpace;
 import org.apache.kato.image.ImageProcess;
+import org.apache.kato.java.JavaRuntime;
 
 
 public class TestImageProcess extends AbstractHProfTestCase {
 
-	
+
 	public void testGetCommandLine() throws IOException, CorruptDataException {
-		
+
 		ImageProcess process=getCurrentProcess();
 		try {
-		process.getCommandLine();
-		fail("expected DataUnavailable exception");
+			process.getCommandLine();
+			fail("expected DataUnavailable exception");
 		} catch(DataUnavailable du) {
-			
+
 		}
-		
-		
+
+
 	}
-	
-public void testGetEnvironment() throws IOException, CorruptDataException {
-		
+
+	public void testGetEnvironment() throws IOException, CorruptDataException {
+
 		ImageProcess process=getCurrentProcess();
 		try {
-		process.getEnvironment();
-		fail("expected DataUnavailable exception");
+			process.getEnvironment();
+			fail("expected DataUnavailable exception");
 		} catch(DataUnavailable du) {
-			
+
 		}
-		
-		
+
+
 	}
 
-public void testGetExecutable() throws IOException, CorruptDataException {
+	public void testGetExecutable() throws IOException, CorruptDataException {
+
+		ImageProcess process=getCurrentProcess();
+		try {
+			process.getExecutable();
+			fail("expected DataUnavailable exception");
+		} catch(DataUnavailable du) {
+
+		}
+
+
+	}
+	public void testGetLibraries() throws IOException, CorruptDataException {
+
+		ImageProcess process=getCurrentProcess();
+		try {
+			process.getLibraries();
+			fail("expected DataUnavailable exception");
+		} catch(DataUnavailable du) {
+
+		}
+
+
+	}
+	public void testGetSignalNumber() throws IOException, CorruptDataException {
+
+		ImageProcess process=getCurrentProcess();
+		try {
+			process.getSignalNumber();
+			fail("expected DataUnavailable exception");
+		} catch(DataUnavailable du) {
+
+		}
+
+
+	}
+	public void testGetSignalName() throws IOException, CorruptDataException {
+
+		ImageProcess process=getCurrentProcess();
+		try {
+			process.getSignalName();
+			fail("expected DataUnavailable exception");
+		} catch(DataUnavailable du) {
+
+		}
+
+
+	}
+
+	public void testGetID() throws IOException, CorruptDataException {
+
+		ImageProcess process=getCurrentProcess();
+		try {
+			process.getID();
+			fail("expected DataUnavailable exception");
+		} catch(DataUnavailable du) {
+
+		}
+
+
+	}
+	public void testGetPointerSize() throws IOException, CorruptDataException {
+
+		ImageProcess process=getCurrentProcess();
+
+		int size=process.getPointerSize();
+		assertTrue("pointer size ("+size+") is less than 1",size>0);
+
+	}
 	
-	ImageProcess process=getCurrentProcess();
-	try {
-	process.getExecutable();
-	fail("expected DataUnavailable exception");
-	} catch(DataUnavailable du) {
+	public void testGetThreadsNotNull() throws Exception {
+		ImageProcess process = getCurrentProcess();
+		
+		Iterator threads = process.getThreads();
 		
+		assertNotNull(threads);
 	}
 	
-	
-}
-public void testGetLibraries() throws IOException, CorruptDataException {
-	
-	ImageProcess process=getCurrentProcess();
-	try {
-	process.getLibraries();
-	fail("expected DataUnavailable exception");
-	} catch(DataUnavailable du) {
+	public void testGetThreadsEmpty() throws Exception {
+		ImageProcess process = getCurrentProcess();
 		
+		Iterator threads = process.getThreads();
+		
+		assertFalse(threads.hasNext());
 	}
 	
-	
-}
-public void testGetSignalNumber() throws IOException, CorruptDataException {
-	
-	ImageProcess process=getCurrentProcess();
-	try {
-	process.getSignalNumber();
-	fail("expected DataUnavailable exception");
-	} catch(DataUnavailable du) {
+	public void testGetCurrentThread() throws Exception {
+		ImageProcess process = getCurrentProcess();
 		
+		assertNull(process.getCurrentThread());
 	}
 	
-	
-}
-public void testGetSignalName() throws IOException, CorruptDataException {
-	
-	ImageProcess process=getCurrentProcess();
-	try {
-	process.getSignalName();
-	fail("expected DataUnavailable exception");
-	} catch(DataUnavailable du) {
+	public void testGetRuntimes() throws Exception {
+		ImageProcess process = getCurrentProcess();
+		
+		Iterator runtimes = process.getRuntimes();
+		int count = 0;
+		
+		while (runtimes.hasNext()) {
+			Object obj = runtimes.next();
+			count++;
+			assertTrue(obj instanceof JavaRuntime);
+		}
 		
+		assertEquals(1, count);
 	}
 	
-	
-}
-
-public void testGetID() throws IOException, CorruptDataException {
-	
-	ImageProcess process=getCurrentProcess();
-	try {
-	process.getID();
-	fail("expected DataUnavailable exception");
-	} catch(DataUnavailable du) {
+	public void testEqualsSelf() throws Exception {
+		ImageProcess process = getCurrentProcess();
 		
+		assertTrue(process.equals(process));
 	}
 	
+	public void testEqualsNull() throws Exception {
+		ImageProcess process = getCurrentProcess();
+		
+		assertFalse(process.equals(null));
+	}
 	
-}
-public void testGetPointerSize() throws IOException, CorruptDataException {
-	
-	ImageProcess process=getCurrentProcess();
-	
-	int size=process.getPointerSize();
-	assertTrue("pointer size ("+size+") is less than 1",size>0);
+	public void testEqualsString() throws Exception {
+		ImageProcess process = getCurrentProcess();
+		
+		assertFalse(process.equals("This is not a Process"));
+	}
 	
-}
+	public void testEqualsOther() throws Exception {
+		ImageProcess populatedProcess = ((ImageAddressSpace)(getPopulatedImage().getAddressSpaces().next())).getCurrentProcess();
+		ImageProcess process = getCurrentProcess();
+		
+		assertFalse(process.equals(populatedProcess));
+	}
 }



Mime
View raw message