incubator-kato-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spo...@apache.org
Subject svn commit: r827016 - in /incubator/kato/branches/experimental/kato.javaview: ./ src/main/java/org/apache/kato/javaview/api/ src/main/java/org/apache/kato/javaview/impl/ src/test/java/test/apache/kato/javaview/ src/test/java/test/apache/kato/javaview/m...
Date Tue, 20 Oct 2009 09:34:58 GMT
Author: spoole
Date: Tue Oct 20 09:34:58 2009
New Revision: 827016

URL: http://svn.apache.org/viewvc?rev=827016&view=rev
Log:
get tests going for new javaview experiment

Added:
    incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/PersistentStore.java
      - copied, changed from r826984, incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/Datastore.java
    incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/PersistentStoreBuilder.java
      - copied, changed from r826984, incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaViewBuilder.java
    incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/
    incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/MockImagePointer.java
    incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/MockJavaClass.java
    incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/MockJavaClassLoader.java
    incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/MockJavaHeap.java
    incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/MockJavaObject.java
    incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/SmallMockJavaRuntime.java
Removed:
    incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/Datastore.java
    incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaViewBuilder.java
Modified:
    incubator/kato/branches/experimental/kato.javaview/pom.xml
    incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/api/QueryResult.java
    incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaClassImpl.java
    incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaClassLoaderImpl.java
    incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaInstanceImpl.java
    incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaViewImpl.java
    incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/SQLDatastore.java
    incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/AbstractPersistentStoreTestCase.java
    incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/TestPersistanceStoreScale.java
    incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/TestPersistentStore.java

Modified: incubator/kato/branches/experimental/kato.javaview/pom.xml
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/pom.xml?rev=827016&r1=827015&r2=827016&view=diff
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/pom.xml (original)
+++ incubator/kato/branches/experimental/kato.javaview/pom.xml Tue Oct 20 09:34:58 2009
@@ -18,7 +18,7 @@
   	<dependency>
   		<groupId>org.apache.derby</groupId>
 		<artifactId>derby</artifactId>
-		<version>10.5.3.0</version>
+		<version>10.4.2.0</version>
   	</dependency>
   	<dependency>
 		<groupId>junit</groupId>
@@ -26,5 +26,10 @@
 		<version>3.8.1</version>
 		<scope>test</scope>
 	</dependency>
+	 <dependency>
+    <groupId>mysql</groupId>
+    <artifactId>mysql-connector-java</artifactId>
+    <version>5.1.6</version>
+</dependency> 
   </dependencies>
 </project>
\ No newline at end of file

Modified: incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/api/QueryResult.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/api/QueryResult.java?rev=827016&r1=827015&r2=827016&view=diff
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/api/QueryResult.java (original)
+++ incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/api/QueryResult.java Tue Oct 20 09:34:58 2009
@@ -32,4 +32,6 @@
     T getElement(long elementNumber) throws IOException;
     
     long getSize() throws IOException;
+
+	void dispose() throws IOException;
 }

Modified: incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaClassImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaClassImpl.java?rev=827016&r1=827015&r2=827016&view=diff
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaClassImpl.java (original)
+++ incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaClassImpl.java Tue Oct 20 09:34:58 2009
@@ -17,13 +17,13 @@
 import org.apache.kato.javaview.api.IJavaClass;
 import org.apache.kato.javaview.api.IJavaClassLoader;
 
-class JavaClassImpl implements IJavaClass {
+public class JavaClassImpl implements IJavaClass {
 	 
 	
 	/**
 	 * 
 	 */
-	private final Datastore store;
+	private final PersistentStore store;
 	private long id=0;
 	private long loader=0;
 	private String name=null;
@@ -31,7 +31,7 @@
 	
 	
 	
-	JavaClassImpl( Datastore store, long id,long loader,String name) {
+	JavaClassImpl( PersistentStore store, long id,long loader,String name) {
 		this.store=store;
 		this.id=id;
 		this.loader=loader;

Modified: incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaClassLoaderImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaClassLoaderImpl.java?rev=827016&r1=827015&r2=827016&view=diff
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaClassLoaderImpl.java (original)
+++ incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaClassLoaderImpl.java Tue Oct 20 09:34:58 2009
@@ -22,11 +22,11 @@
 
 
 	private long id=0;
-	private Datastore store=null;
+	private PersistentStore store=null;
 	
 	
 	
-	JavaClassLoaderImpl(Datastore store,long id) {
+	JavaClassLoaderImpl(PersistentStore store,long id) {
 		this.id=id;
 		this.store=store;
 	

Modified: incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaInstanceImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaInstanceImpl.java?rev=827016&r1=827015&r2=827016&view=diff
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaInstanceImpl.java (original)
+++ incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaInstanceImpl.java Tue Oct 20 09:34:58 2009
@@ -22,10 +22,10 @@
 
 class JavaInstanceImpl implements IJavaInstance{
 
-	private Datastore store=null;
+	private PersistentStore store=null;
 	private long id=0;
 	private long clazzid=0;
-	public JavaInstanceImpl(Datastore store,long id, long clazzid) {
+	public JavaInstanceImpl(PersistentStore store,long id, long clazzid) {
 		this.store=store;
 		this.id=id;
 		this.clazzid=clazzid;

Modified: incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaViewImpl.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaViewImpl.java?rev=827016&r1=827015&r2=827016&view=diff
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaViewImpl.java (original)
+++ incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaViewImpl.java Tue Oct 20 09:34:58 2009
@@ -27,7 +27,7 @@
 import org.apache.kato.javaview.api.IJavaInstance;
 import org.apache.kato.javaview.api.IJavaView;
 import org.apache.kato.javaview.api.QueryResult;
-import org.apache.kato.javaview.impl.Datastore;
+import org.apache.kato.javaview.impl.PersistentStore;
 import org.apache.kato.javaview.impl.JavaClassImpl;
 import org.apache.kato.javaview.impl.JavaClassLoaderImpl;
 import org.apache.kato.javaview.impl.JavaInstanceImpl;
@@ -35,10 +35,10 @@
 public 
 class JavaViewImpl implements IJavaView {
 
-	Datastore store=null;
+	PersistentStore store=null;
 	private JavaRuntime runtime=null;
 	
-	public JavaViewImpl(JavaRuntime jrt, Datastore store) {
+	public JavaViewImpl(JavaRuntime jrt, PersistentStore store) {
 		this.store=store;
 		this.runtime=jrt;
 	}
@@ -53,110 +53,4 @@
 		// TODO Auto-generated method stub
 		return null;
 	}
-	
-void addInstances() {
-	
-		
-		for(JavaHeap h: runtime.getHeaps()) {
-			for(JavaObject o:h.getObjects()) {
-				try {
-					JavaClass clazz=o.getJavaClass();
-					long clazzid=clazz.getID().getAddress();
-					JavaClassImpl clazzImpl=store.getJavaClass(clazzid);
-					if(clazzImpl==null) {
-						System.out.println("cant find record for "+clazz.getName());
-					}
-					else {
-					long id=o.getID().getAddress();
-					JavaInstanceImpl impl=new JavaInstanceImpl(store,id,clazzid);
-					store.addJavaInstance(impl);
-					
-					
-					}
-					
-				} catch (CorruptDataException e) {
-					// TODO Auto-generated catch block
-					e.printStackTrace();
-				}
-				
-				
-				
-			}
-		}
-		
-	
-		
-	}
-
-	 void addClassLoaders() {
-		
-		
-		
-		int count=0;
-		for(JavaClassLoader jcl:runtime.getJavaClassLoaders()) {
-			
-			
-			long id=1;
-			count++;
-			
-			JavaObject o;
-			try {
-				o = jcl.getObject();
-			
-			if(o!=null) id=o.getID().getAddress();
-			JavaClassLoaderImpl i=new JavaClassLoaderImpl(store,id);
-			store.addJavaClassLoader(i);
-			
-			// add classes...
-			
-			addClasses(store, jcl.getCachedClasses());
-			addClasses(store, jcl.getDefinedClasses());
-			
-			
-			
-			
-			} catch (CorruptDataException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
-			}
-		}
-		System.out.println("Added "+count+" loaders");
-		
-	}
-
-	 void addClasses(Datastore store, List<JavaClass> list)
-			throws CorruptDataException {
-		for(JavaClass clazz:list) {
-			String name=clazz.getName();
-			long clazzid=clazz.getID().getAddress();
-			long loaderid=1;
-			
-			JavaClassLoader loader=clazz.getClassLoader();
-			if(loader!=null) {
-				JavaObject lobj=loader.getObject();
-				if(lobj!=null) {
-					loaderid=lobj.getID().getAddress();
-				}
-				
-			}
-			
-			clazz.getClassLoader().getObject().getID().getAddress();
-			JavaClassImpl clazzImpl=store.getJavaClass(clazzid);
-			if(clazzImpl==null) {
-				clazzImpl=new JavaClassImpl(store, clazzid,loaderid,name);
-				store.addJavaClass(clazzImpl);
-			}
-			else {
-				String oldName=store.getJavaClass(clazzid).getName();
-				if(oldName.equals(name)==false) {
-					throw new IllegalArgumentException(oldName+" != "+name);
-				}
-			}
-			
-			
-			//clazzImpl.setLoader(impl);
-			//impl.addCachedClass(clazzImpl);
-			
-		}
-	}
 }
\ No newline at end of file

Copied: incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/PersistentStore.java (from r826984, incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/Datastore.java)
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/PersistentStore.java?p2=incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/PersistentStore.java&p1=incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/Datastore.java&r1=826984&r2=827016&rev=827016&view=diff
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/Datastore.java (original)
+++ incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/PersistentStore.java Tue Oct 20 09:34:58 2009
@@ -16,9 +16,12 @@
 
 import java.io.IOException;
 
+import org.apache.kato.javaview.api.IJavaClass;
+import org.apache.kato.javaview.api.QueryResult;
+
 
 public 
- interface Datastore {
+ interface PersistentStore {
 
 	public void open() throws IOException;
 	
@@ -35,4 +38,6 @@
 	JavaClassLoaderImpl getJavaClassLoader(long loader);
 
 	public void close() throws IOException;
+
+	public QueryResult<IJavaClass> getAllClasses() throws IOException;
 }

Copied: incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/PersistentStoreBuilder.java (from r826984, incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaViewBuilder.java)
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/PersistentStoreBuilder.java?p2=incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/PersistentStoreBuilder.java&p1=incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaViewBuilder.java&r1=826984&r2=827016&rev=827016&view=diff
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/JavaViewBuilder.java (original)
+++ incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/PersistentStoreBuilder.java Tue Oct 20 09:34:58 2009
@@ -14,36 +14,155 @@
 
 package org.apache.kato.javaview.impl;
 
+import java.io.File;
 import java.io.IOException;
+import java.util.List;
 
+import javax.tools.diagnostics.image.CorruptDataException;
+import javax.tools.diagnostics.runtime.java.JavaClass;
+import javax.tools.diagnostics.runtime.java.JavaClassLoader;
+import javax.tools.diagnostics.runtime.java.JavaHeap;
+import javax.tools.diagnostics.runtime.java.JavaObject;
 import javax.tools.diagnostics.runtime.java.JavaRuntime;
 
 import org.apache.kato.javaview.api.IJavaView;
 
 
 
-public class JavaViewBuilder {
+public class PersistentStoreBuilder {
 
 	
-	public  static IJavaView buildView(JavaRuntime jrt) throws IOException {
+	public PersistentStoreBuilder(File cacheDir) {
+		
+	}
+	
+	public  PersistentStore buildStore(JavaRuntime jrt) throws IOException {
 		
 		if(jrt==null) throw new IllegalArgumentException("runtime is null");
 		
-		Datastore s=new SQLDatastore("jdbc:mysql://localhost/javaview");
+		PersistentStore s=new SQLDatastore("jdbc:mysql://localhost/javaview");
 		s.open();
-		JavaViewImpl impl=new JavaViewImpl(jrt,s);
+		
 		
 		// add all the class loaders...
 		
-		impl.addClassLoaders();
-		impl.addInstances();
+		addClassLoaders(jrt,s);
+		addInstances(jrt,s);
+		
+	
+		
+		return  s;
+		
+	}
+
+	private static void addInstances(JavaRuntime runtime, PersistentStore store) {
+	
+		
+		for(JavaHeap h: runtime.getHeaps()) {
+			for(JavaObject o:h.getObjects()) {
+				try {
+					JavaClass clazz=o.getJavaClass();
+					if(clazz==null) {
+						System.out.println("Object without class");
+						continue;
+					}
+					long clazzid=clazz.getID().getAddress();
+					JavaClassImpl clazzImpl=store.getJavaClass(clazzid);
+					if(clazzImpl==null) {
+						System.out.println("cant find record for "+clazz.getName());
+					}
+					else {
+					long id=o.getID().getAddress();
+					JavaInstanceImpl impl=new JavaInstanceImpl(store,id,clazzid);
+					store.addJavaInstance(impl);
+					
+					
+					}
+					
+				} catch (CorruptDataException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+				
+				
+				
+			}
+		}
+		
+	
+		
+	}
+
+	private static void addClassLoaders(JavaRuntime runtime, PersistentStore store) {
+		
 		
-		s.close();
 		
-		return  impl;
+		int count=0;
+		for(JavaClassLoader jcl:runtime.getJavaClassLoaders()) {
+			
+			
+			long id=1;
+			count++;
+			
+			JavaObject o;
+			try {
+				o = jcl.getObject();
+			
+			if(o!=null) id=o.getID().getAddress();
+			JavaClassLoaderImpl i=new JavaClassLoaderImpl(store,id);
+			store.addJavaClassLoader(i);
+			
+			// add classes...
+			
+			addClasses(store, jcl.getCachedClasses());
+			addClasses(store, jcl.getDefinedClasses());
+			
+			
+			
+			
+			} catch (CorruptDataException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+		}
+		System.out.println("Added "+count+" loaders");
 		
 	}
 
+	private static void addClasses(PersistentStore store, List<JavaClass> list)
+			throws CorruptDataException {
+		for(JavaClass clazz:list) {
+			String name=clazz.getName();
+			long clazzid=clazz.getID().getAddress();
+			long loaderid=1;
+			
+			JavaClassLoader loader=clazz.getClassLoader();
+			if(loader!=null) {
+				JavaObject lobj=loader.getObject();
+				if(lobj!=null) {
+					loaderid=lobj.getID().getAddress();
+				}
+			}
+			
+			JavaClassImpl clazzImpl=store.getJavaClass(clazzid);
+			if(clazzImpl==null) {
+				clazzImpl=new JavaClassImpl(store, clazzid,loaderid,name);
+				store.addJavaClass(clazzImpl);
+			}
+			else {
+				String oldName=store.getJavaClass(clazzid).getName();
+				if(oldName.equals(name)==false) {
+					throw new IllegalArgumentException(oldName+" != "+name);
+				}
+			}
+			
+			
+			//clazzImpl.setLoader(impl);
+			//impl.addCachedClass(clazzImpl);
+			
+		}
+	}
+
 	
 
 		

Modified: incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/SQLDatastore.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/SQLDatastore.java?rev=827016&r1=827015&r2=827016&view=diff
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/SQLDatastore.java (original)
+++ incubator/kato/branches/experimental/kato.javaview/src/main/java/org/apache/kato/javaview/impl/SQLDatastore.java Tue Oct 20 09:34:58 2009
@@ -7,8 +7,12 @@
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.util.Iterator;
 
-public class SQLDatastore implements Datastore{
+import org.apache.kato.javaview.api.IJavaClass;
+import org.apache.kato.javaview.api.QueryResult;
+
+public class SQLDatastore implements PersistentStore{
 
 	Connection connection=null;
 	PreparedStatement insertInstance=null;
@@ -172,4 +176,75 @@
 		
 		
 	}
+
+	@Override
+	public QueryResult<IJavaClass> getAllClasses() throws IOException {
+		
+		try {
+			Statement s=connection.createStatement();
+			final ResultSet rs=s.executeQuery("select * from classes");
+			return new QueryResult<IJavaClass>() {
+
+				@Override
+				public void applyFilter(String filter) {
+					// TODO Auto-generated method stub
+					
+				}
+
+				@Override
+				public void dispose() throws IOException {
+					try {
+						rs.close();
+					} catch (SQLException e) {
+						throw new IOException(e);
+					}
+					
+				}
+
+				@Override
+				public QueryResult<IJavaClass> filterSet(String filter) {
+					// TODO Auto-generated method stub
+					return null;
+				}
+
+				@Override
+				public IJavaClass getElement(long elementNumber)
+						throws IOException {
+					// TODO Auto-generated method stub
+					return null;
+				}
+
+				@Override
+				public long getSize() throws IOException {
+					
+				    try {
+						int current=rs.getRow();
+						rs.last();
+						long size=rs.getRow();
+						if(current==0)  rs.beforeFirst();
+						else rs.absolute(current);
+						return size;
+					} catch (SQLException e) {
+					throw new IOException(e);
+					}
+				    
+				}
+
+				@Override
+				public QueryResult<?> query(String filter) {
+					// TODO Auto-generated method stub
+					return null;
+				}
+
+				@Override
+				public Iterator<IJavaClass> iterator() {
+					// TODO Auto-generated method stub
+					return null;
+				}
+			};
+		} catch (SQLException e) {
+			throw new IOException(e);
+		}
+	
+	}
 }

Modified: incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/AbstractPersistentStoreTestCase.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/AbstractPersistentStoreTestCase.java?rev=827016&r1=827015&r2=827016&view=diff
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/AbstractPersistentStoreTestCase.java (original)
+++ incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/AbstractPersistentStoreTestCase.java Tue Oct 20 09:34:58 2009
@@ -18,11 +18,11 @@
 
 import javax.tools.diagnostics.runtime.java.JavaRuntime;
 
+import junit.framework.TestCase;
+
 import org.apache.kato.javaview.impl.PersistentStore;
 import org.apache.kato.javaview.impl.PersistentStoreBuilder;
 
-import junit.framework.TestCase;
-
 public abstract class AbstractPersistentStoreTestCase  extends TestCase{
 
 	protected void deleteFile(File dir) {

Modified: incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/TestPersistanceStoreScale.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/TestPersistanceStoreScale.java?rev=827016&r1=827015&r2=827016&view=diff
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/TestPersistanceStoreScale.java (original)
+++ incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/TestPersistanceStoreScale.java Tue Oct 20 09:34:58 2009
@@ -16,62 +16,33 @@
 import java.io.File;
 import java.io.IOException;
 
-import javax.tools.diagnostics.FactoryRegistry;
-import javax.tools.diagnostics.image.CorruptDataException;
-import javax.tools.diagnostics.runtime.java.JavaClass;
-import javax.tools.diagnostics.runtime.java.JavaHeap;
-import javax.tools.diagnostics.runtime.java.JavaObject;
 import javax.tools.diagnostics.runtime.java.JavaRuntime;
 
+import org.apache.kato.javaview.api.IJavaClass;
+import org.apache.kato.javaview.api.QueryResult;
 import org.apache.kato.javaview.impl.PersistentStore;
-import org.apache.kato.javaview.impl.Table;
+
+import test.apache.kato.javaview.mockdata.SmallMockJavaRuntime;
+
 
 public class TestPersistanceStoreScale extends AbstractPersistentStoreTestCase {
 
+	static String testname=TestPersistanceStoreScale.class.getCanonicalName();
 	
 	public void testLoadPersistentStore() throws IOException {
 		
-		File base=new File("C:\\Documents and Settings\\spoole\\Desktop\\core.core");
 		
-		JavaRuntime jrt=FactoryRegistry.getDefaultRegistry().getJavaRuntime(base);
-		assertNotNull(jrt);
+		File f=new File("foo");
 		
-	
+		JavaRuntime jrt=new SmallMockJavaRuntime(f);
 		PersistentStore store=getStore(jrt);
 		
-		int count=0;
-		int cycle=0;
-		int cdeCount=0;
-		// add in class object data
-		
-		Table table=store.getClassObjectTable();
-		
-		for(JavaHeap heap:jrt.getHeaps()) {
-			for(JavaObject object:heap.getObjects()) {
-				try {
-					JavaClass clazz=object.getJavaClass();
-					if(clazz!=null) {
-						long clazz_addr=clazz.getID().getAddress();
-						long obj_addr=object.getID().getAddress();
-						table.put(clazz_addr,obj_addr);
-						count++;
-						cycle++;
-						if(cycle>1000) {
-							cycle=0;
-							System.out.print("Count "+count+" errs="+cdeCount);
-						}
-					}
-				} catch (CorruptDataException e) {
-					cdeCount++;
-				}
-				
-			}
-		}
-		
-		long records=table.setSize();
+		QueryResult<IJavaClass>  clazzes=store.getAllClasses();
+		long size=clazzes.getSize();
+		clazzes.dispose();
 		store.close();
 		
-		assertEquals(3,records);
+		assertEquals(3,size);
 		
 		
 	}

Modified: incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/TestPersistentStore.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/TestPersistentStore.java?rev=827016&r1=827015&r2=827016&view=diff
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/TestPersistentStore.java (original)
+++ incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/TestPersistentStore.java Tue Oct 20 09:34:58 2009
@@ -38,403 +38,17 @@
 
 import junit.framework.TestCase;
 
+import org.apache.kato.javaview.api.IJavaClass;
+import org.apache.kato.javaview.api.QueryResult;
 import org.apache.kato.javaview.impl.PersistentStore;
 import org.apache.kato.javaview.impl.Table;
 
+import test.apache.kato.javaview.mockdata.SmallMockJavaRuntime;
+
 public class TestPersistentStore extends AbstractPersistentStoreTestCase {
 
-	private static long lastaddr=0;
 	
-	private final class MockPointer implements ImagePointer {
-		
-		private long addr=0;
-		public MockPointer(long addr) {
-			this.addr=addr;
-		}
-
-		@Override
-		public ImagePointer add(long offset) {
-			// TODO Auto-generated method stub
-			return null;
-		}
-
-		@Override
-		public long getAddress() {
-			return addr;
-		}
-
-		@Override
-		public ImageAddressSpace getAddressSpace() {
-			// TODO Auto-generated method stub
-			return null;
-		}
-
-		@Override
-		public byte getByteAt(long index)
-				throws MemoryAccessException, CorruptDataException {
-			// TODO Auto-generated method stub
-			return 0;
-		}
-
-		@Override
-		public double getDoubleAt(long index)
-				throws MemoryAccessException, CorruptDataException {
-			// TODO Auto-generated method stub
-			return 0;
-		}
-
-		@Override
-		public float getFloatAt(long index)
-				throws MemoryAccessException, CorruptDataException {
-			// TODO Auto-generated method stub
-			return 0;
-		}
-
-		@Override
-		public int getIntAt(long index)
-				throws MemoryAccessException, CorruptDataException {
-			// TODO Auto-generated method stub
-			return 0;
-		}
-
-		@Override
-		public long getLongAt(long index)
-				throws MemoryAccessException, CorruptDataException {
-			// TODO Auto-generated method stub
-			return 0;
-		}
-
-		@Override
-		public ImagePointer getPointerAt(long index)
-				throws MemoryAccessException, CorruptDataException {
-			// TODO Auto-generated method stub
-			return null;
-		}
-
-		@Override
-		public short getShortAt(long index)
-				throws MemoryAccessException, CorruptDataException {
-			// TODO Auto-generated method stub
-			return 0;
-		}
-
-		@Override
-		public boolean isExecutable() throws DataUnavailable {
-			// TODO Auto-generated method stub
-			return false;
-		}
-
-		@Override
-		public boolean isReadOnly() throws DataUnavailable {
-			// TODO Auto-generated method stub
-			return false;
-		}
-
-		@Override
-		public boolean isShared() throws DataUnavailable {
-			// TODO Auto-generated method stub
-			return false;
-		}
-	}
-	private final class MockJavaRuntime implements JavaRuntime {
-		
-		private final class MockJavaObject implements JavaObject {
-			
-			private JavaClass clazz=null;
-			private long addr=0;			
-			public MockJavaObject(JavaClass c1) {
-				this.clazz=c1;
-					lastaddr++;
-					addr=lastaddr;
-
-			}
-
-			@Override
-			public boolean isArray() throws CorruptDataException {
-				// TODO Auto-generated method stub
-				return false;
-			}
-
-			@Override
-			public long getSize() throws CorruptDataException {
-			
-				return 0;
-			}
-
-			@Override
-			public List<ImageSection> getSections() {
-			
-				return null;
-			}
-
-			@Override
-			public List<JavaReference> getReferences() {
-			
-				return null;
-			}
-
-			@Override
-			public long getPersistentHashcode() throws DataUnavailable,
-					CorruptDataException {
-			
-				return 0;
-			}
-
-			@Override
-			public JavaClass getJavaClass() throws CorruptDataException {
-				return clazz;
-			}
-
-			@Override
-			public ImagePointer getID() {
-			return new MockPointer(addr);
-			}
-
-			@Override
-			public JavaHeap getHeap() throws CorruptDataException, DataUnavailable {
-				// TODO Auto-generated method stub
-				return null;
-			}
-
-			@Override
-			public long getHashcode() throws DataUnavailable, CorruptDataException {
-				// TODO Auto-generated method stub
-				return 0;
-			}
-
-			@Override
-			public int getArraySize() throws CorruptDataException {
-				// TODO Auto-generated method stub
-				return 0;
-			}
-
-			@Override
-			public void arraycopy(int srcStart, Object dst, int dstStart, int length)
-					throws CorruptDataException, MemoryAccessException {
-				// TODO Auto-generated method stub
-				
-			}
-		}
-
-		private final class MockJavaClass implements JavaClass {
-			
-			
-
-			private long addr=0;
-			public MockJavaClass() {
-			
-				lastaddr++;
-				addr=lastaddr;
-			}
-
-			
-			 
-			
-			@Override
-			public JavaClassLoader getClassLoader()
-					throws CorruptDataException {
-				// TODO Auto-generated method stub
-				return null;
-			}
-
-			@Override
-			public JavaClass getComponentType() throws CorruptDataException {
-				// TODO Auto-generated method stub
-				return null;
-			}
-
-			@Override
-			public List<JavaObject> getConstantPoolReferences() {
-			
-				return null;
-			}
-
-			@Override
-			public List<JavaField> getDeclaredFields() {
-			
-				return null;
-			}
-
-			@Override
-			public List<JavaMethod> getDeclaredMethods() {
-			
-				return null;
-			}
-
-			@Override
-			public ImagePointer getID() {
-			 
-				return new MockPointer(addr);
-			}
-
-			@Override
-			public List<String> getInterfaces() {
-			
-				return null;
-			}
-
-			@Override
-			public int getModifiers() throws CorruptDataException {
-				// TODO Auto-generated method stub
-				return 0;
-			}
-
-			@Override
-			public String getName() throws CorruptDataException {
-				// TODO Auto-generated method stub
-				return null;
-			}
-
-			@Override
-			public JavaObject getObject() throws CorruptDataException {
-				// TODO Auto-generated method stub
-				return null;
-			}
-
-			@Override
-			public List<JavaReference> getReferences() {
-				// TODO Auto-generated method stub
-				return null;
-			}
-
-			@Override
-			public JavaClass getSuperclass() throws CorruptDataException {
-				// TODO Auto-generated method stub
-				return null;
-			}
-
-			@Override
-			public boolean isArray() throws CorruptDataException {
-				// TODO Auto-generated method stub
-				return false;
-			}
-		}
-
-		private final class MockHeap implements JavaHeap {
-			private final List<JavaObject> objects;
-
-			private MockHeap(List<JavaObject> objects) {
-				this.objects = objects;
-			}
-
-			@Override
-			public String getName() {
-				// TODO Auto-generated method stub
-				return null;
-			}
-
-			@Override
-			public List<JavaObject> getObjects() {
-				return objects;
-			}
-
-			@Override
-			public List<ImageSection> getSections() {
-				// TODO Auto-generated method stub
-				return null;
-			}
-		}
-
-		List<JavaHeap> heaps=new LinkedList<JavaHeap>();
-		public MockJavaRuntime() {
-			
-			JavaClass  c1=new MockJavaClass();
-			JavaObject a1=new MockJavaObject(c1);
-			JavaClass  c2=new MockJavaClass();
-			JavaObject b1=new MockJavaObject(c2);
-			JavaObject b2=new MockJavaObject(c2);
-			
-			final List<JavaObject> objects=new LinkedList<JavaObject>();
-			objects.add(a1);
-			objects.add(b1);
-			objects.add(b2);
-			
-			heaps.add(new MockHeap(objects));
-		}
-
-		
-		
-		@Override
-		public String getVersion() throws CorruptDataException {
-			// TODO Auto-generated method stub
-			return null;
-		}
-
-		@Override
-		public String getFullVersion() throws CorruptDataException {
-			// TODO Auto-generated method stub
-			return null;
-		}
-
-		@Override
-		public Object getTraceBuffer(String bufferName, boolean formatted)
-				throws CorruptDataException {
-			// TODO Auto-generated method stub
-			return null;
-		}
-
-		@Override
-		public List<JavaThread> getThreads() {
-			// TODO Auto-generated method stub
-			return null;
-		}
-
-		@Override
-		public File getSource() {
-			return new File("testfile.txt");
-		}
-
-		@Override
-		public JavaObject getObjectAtAddress(ImagePointer address)
-				throws CorruptDataException, IllegalArgumentException,
-				MemoryAccessException, DataUnavailable {
-			// TODO Auto-generated method stub
-			return null;
-		}
-
-		@Override
-		public List<JavaMonitor> getMonitors() {
-			// TODO Auto-generated method stub
-			return null;
-		}
-
-		@Override
-		public JavaVMInitArgs getJavaVMInitArgs() throws DataUnavailable,
-				CorruptDataException {
-			// TODO Auto-generated method stub
-			return null;
-		}
-
-		@Override
-		public ImagePointer getJavaVM() throws CorruptDataException {
-			// TODO Auto-generated method stub
-			return null;
-		}
-
-		@Override
-		public List<JavaClassLoader> getJavaClassLoaders() {
-			// TODO Auto-generated method stub
-			return null;
-		}
-
-		@Override
-		public List<JavaHeap> getHeaps() {
-			return heaps;
-		}
-
-		@Override
-		public List<JavaReference> getHeapRoots() {
-			// TODO Auto-generated method stub
-			return null;
-		}
-
-		@Override
-		public List<JavaMethod> getCompiledMethods() {
-			// TODO Auto-generated method stub
-			return null;
-		}
-	}
-
+	
 	/**
 	 * Test we can create a persistent store from scratch
 	 * @throws IOException
@@ -451,37 +65,21 @@
 			}
 		}
 		
-		getStore(new MockJavaRuntime());
+		getStore(new SmallMockJavaRuntime(storeDir));
 	}
 	 
 	public void testSmallPopulateClassObjectTable() throws IOException {
 		
-		JavaRuntime jrt=new MockJavaRuntime();
+		JavaRuntime jrt=new SmallMockJavaRuntime(null);
+		
 		PersistentStore store=getStore(jrt);
 		
 		// add in class object data
+		QueryResult<IJavaClass> table=store.getAllClasses();
 		
-		Table table=store.getClassObjectTable();
-		
-		for(JavaHeap heap:jrt.getHeaps()) {
-			for(JavaObject object:heap.getObjects()) {
-				try {
-					JavaClass clazz=object.getJavaClass();
-					if(clazz!=null) {
-						long clazz_addr=clazz.getID().getAddress();
-						long obj_addr=object.getID().getAddress();
-						table.put(clazz_addr,obj_addr);
-					}
-				} catch (CorruptDataException e) {
-					
-				}
-				
-			}
-		}
-		
-		long records=table.setSize();
+		long records=table.getSize();
+		table.dispose();
 		store.close();
-		
 		assertEquals(3,records);
 		
 		

Added: incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/MockImagePointer.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/MockImagePointer.java?rev=827016&view=auto
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/MockImagePointer.java (added)
+++ incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/MockImagePointer.java Tue Oct 20 09:34:58 2009
@@ -0,0 +1,102 @@
+/**
+ * 
+ */
+package test.apache.kato.javaview.mockdata;
+
+import javax.tools.diagnostics.image.CorruptDataException;
+import javax.tools.diagnostics.image.DataUnavailable;
+import javax.tools.diagnostics.image.ImageAddressSpace;
+import javax.tools.diagnostics.image.ImagePointer;
+import javax.tools.diagnostics.image.MemoryAccessException;
+
+class MockImagePointer implements ImagePointer {
+	
+	private long id=0;
+	public MockImagePointer(long id) {
+		this.id=id;
+	}
+	@Override
+	public ImagePointer add(long offset) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public long getAddress() {
+		
+		return this.id;
+	}
+
+	@Override
+	public ImageAddressSpace getAddressSpace() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public byte getByteAt(long index) throws MemoryAccessException,
+			CorruptDataException {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	@Override
+	public double getDoubleAt(long index)
+			throws MemoryAccessException, CorruptDataException {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	@Override
+	public float getFloatAt(long index)
+			throws MemoryAccessException, CorruptDataException {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	@Override
+	public int getIntAt(long index) throws MemoryAccessException,
+			CorruptDataException {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	@Override
+	public long getLongAt(long index) throws MemoryAccessException,
+			CorruptDataException {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	@Override
+	public ImagePointer getPointerAt(long index)
+			throws MemoryAccessException, CorruptDataException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public short getShortAt(long index)
+			throws MemoryAccessException, CorruptDataException {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	@Override
+	public boolean isExecutable() throws DataUnavailable {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public boolean isReadOnly() throws DataUnavailable {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	@Override
+	public boolean isShared() throws DataUnavailable {
+		// TODO Auto-generated method stub
+		return false;
+	}
+}
\ No newline at end of file

Added: incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/MockJavaClass.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/MockJavaClass.java?rev=827016&view=auto
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/MockJavaClass.java (added)
+++ incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/MockJavaClass.java Tue Oct 20 09:34:58 2009
@@ -0,0 +1,108 @@
+/**
+ * 
+ */
+package test.apache.kato.javaview.mockdata;
+
+import java.util.List;
+
+import javax.tools.diagnostics.image.CorruptDataException;
+import javax.tools.diagnostics.image.ImagePointer;
+import javax.tools.diagnostics.runtime.java.JavaClass;
+import javax.tools.diagnostics.runtime.java.JavaClassLoader;
+import javax.tools.diagnostics.runtime.java.JavaField;
+import javax.tools.diagnostics.runtime.java.JavaMethod;
+import javax.tools.diagnostics.runtime.java.JavaObject;
+import javax.tools.diagnostics.runtime.java.JavaReference;
+
+final class MockJavaClass implements JavaClass {
+	private static long lastclazzID=1000;
+	private long clazzid=0;
+	private String name=null;
+	private JavaClassLoader loader=null;
+	
+	
+	public MockJavaClass(String name,JavaClassLoader loader) {
+		lastclazzID++;
+		clazzid=lastclazzID;
+		this.name=name;
+		this.loader=loader;
+	}
+
+	@Override
+	public JavaClassLoader getClassLoader()
+			throws CorruptDataException {
+		return loader;
+	}
+
+	@Override
+	public JavaClass getComponentType() throws CorruptDataException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public List<JavaObject> getConstantPoolReferences() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public List<JavaField> getDeclaredFields() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public List<JavaMethod> getDeclaredMethods() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public ImagePointer getID() {
+		
+		return new MockImagePointer(clazzid);
+	}
+
+	@Override
+	public List<String> getInterfaces() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public int getModifiers() throws CorruptDataException {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	@Override
+	public String getName() throws CorruptDataException {
+		
+		return name;
+	}
+
+	@Override
+	public JavaObject getObject() throws CorruptDataException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public List<JavaReference> getReferences() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public JavaClass getSuperclass() throws CorruptDataException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public boolean isArray() throws CorruptDataException {
+		// TODO Auto-generated method stub
+		return false;
+	}
+}
\ No newline at end of file

Added: incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/MockJavaClassLoader.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/MockJavaClassLoader.java?rev=827016&view=auto
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/MockJavaClassLoader.java (added)
+++ incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/MockJavaClassLoader.java Tue Oct 20 09:34:58 2009
@@ -0,0 +1,43 @@
+package test.apache.kato.javaview.mockdata;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.tools.diagnostics.image.CorruptDataException;
+import javax.tools.diagnostics.runtime.java.JavaClass;
+import javax.tools.diagnostics.runtime.java.JavaClassLoader;
+import javax.tools.diagnostics.runtime.java.JavaObject;
+
+public class MockJavaClassLoader implements JavaClassLoader {
+
+	List<JavaClass> clazzes=new LinkedList<JavaClass>();
+	
+	@Override
+	public JavaClass findClass(String name) throws CorruptDataException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public List<JavaClass> getCachedClasses() {
+		return clazzes;
+	}
+
+	@Override
+	public List<JavaClass> getDefinedClasses() {
+	
+		return clazzes;
+	}
+
+	@Override
+	public JavaObject getObject() throws CorruptDataException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public void addClass(JavaClass javaClass) {
+		clazzes.add(javaClass);
+		
+	}
+
+}

Added: incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/MockJavaHeap.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/MockJavaHeap.java?rev=827016&view=auto
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/MockJavaHeap.java (added)
+++ incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/MockJavaHeap.java Tue Oct 20 09:34:58 2009
@@ -0,0 +1,36 @@
+package test.apache.kato.javaview.mockdata;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.tools.diagnostics.image.ImageSection;
+import javax.tools.diagnostics.runtime.java.JavaHeap;
+import javax.tools.diagnostics.runtime.java.JavaObject;
+
+public class MockJavaHeap implements JavaHeap{
+
+	private List<JavaObject> objects=new LinkedList<JavaObject>();
+	@Override
+	public String getName() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public List<JavaObject> getObjects() {
+		
+		return objects;
+	}
+
+	@Override
+	public List<ImageSection> getSections() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public void add(MockJavaObject mockJavaObject) {
+		objects.add(mockJavaObject);
+		
+	}
+
+}

Added: incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/MockJavaObject.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/MockJavaObject.java?rev=827016&view=auto
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/MockJavaObject.java (added)
+++ incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/MockJavaObject.java Tue Oct 20 09:34:58 2009
@@ -0,0 +1,105 @@
+/**
+ * 
+ */
+package test.apache.kato.javaview.mockdata;
+
+import java.util.List;
+
+import javax.tools.diagnostics.image.CorruptDataException;
+import javax.tools.diagnostics.image.DataUnavailable;
+import javax.tools.diagnostics.image.ImagePointer;
+import javax.tools.diagnostics.image.ImageSection;
+import javax.tools.diagnostics.image.MemoryAccessException;
+import javax.tools.diagnostics.runtime.java.JavaClass;
+import javax.tools.diagnostics.runtime.java.JavaHeap;
+import javax.tools.diagnostics.runtime.java.JavaObject;
+import javax.tools.diagnostics.runtime.java.JavaReference;
+
+final class MockJavaObject implements JavaObject {
+	private static long lastID=1000;
+	private long id=0;
+	private JavaClass clazz=null;
+	
+	public MockJavaObject(JavaClass clazz) {
+		lastID++;
+		id=lastID;
+		this.clazz=clazz;
+	}
+
+	@Override
+	public void arraycopy(int srcStart, Object dst,
+			int dstStart, int length)
+			throws CorruptDataException,
+			MemoryAccessException {
+		// TODO Auto-generated method stub
+		
+	}
+
+	@Override
+	public int getArraySize()
+			throws CorruptDataException {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	@Override
+	public long getHashcode() throws DataUnavailable,
+			CorruptDataException {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	@Override
+	public JavaHeap getHeap()
+			throws CorruptDataException,
+			DataUnavailable {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public ImagePointer getID() {
+		
+		return new MockImagePointer(id);
+	}
+
+	@Override
+	public JavaClass getJavaClass()
+			throws CorruptDataException {
+		
+		return clazz;
+	}
+
+	@Override
+	public long getPersistentHashcode()
+			throws DataUnavailable,
+			CorruptDataException {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	@Override
+	public List<JavaReference> getReferences() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public List<ImageSection> getSections() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public long getSize() throws CorruptDataException {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	@Override
+	public boolean isArray()
+			throws CorruptDataException {
+		// TODO Auto-generated method stub
+		return false;
+	}
+}
\ No newline at end of file

Added: incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/SmallMockJavaRuntime.java
URL: http://svn.apache.org/viewvc/incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/SmallMockJavaRuntime.java?rev=827016&view=auto
==============================================================================
--- incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/SmallMockJavaRuntime.java (added)
+++ incubator/kato/branches/experimental/kato.javaview/src/test/java/test/apache/kato/javaview/mockdata/SmallMockJavaRuntime.java Tue Oct 20 09:34:58 2009
@@ -0,0 +1,134 @@
+/**
+ * 
+ */
+package test.apache.kato.javaview.mockdata;
+
+import java.io.File;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.tools.diagnostics.image.CorruptDataException;
+import javax.tools.diagnostics.image.DataUnavailable;
+import javax.tools.diagnostics.image.ImagePointer;
+import javax.tools.diagnostics.image.MemoryAccessException;
+import javax.tools.diagnostics.runtime.java.JavaClass;
+import javax.tools.diagnostics.runtime.java.JavaClassLoader;
+import javax.tools.diagnostics.runtime.java.JavaHeap;
+import javax.tools.diagnostics.runtime.java.JavaMethod;
+import javax.tools.diagnostics.runtime.java.JavaMonitor;
+import javax.tools.diagnostics.runtime.java.JavaObject;
+import javax.tools.diagnostics.runtime.java.JavaReference;
+import javax.tools.diagnostics.runtime.java.JavaRuntime;
+import javax.tools.diagnostics.runtime.java.JavaThread;
+import javax.tools.diagnostics.runtime.java.JavaVMInitArgs;
+
+
+public class SmallMockJavaRuntime implements JavaRuntime {
+	
+	private JavaClass[] clazzes=null;
+	private List<JavaClassLoader> loaders=null;
+	private File source=null;
+	private List<JavaHeap>  heaps=null;
+	
+	public SmallMockJavaRuntime(File source) {
+		this.source=source;
+		clazzes=new JavaClass[3];
+		loaders=new LinkedList<JavaClassLoader>();
+		MockJavaClassLoader loader=new MockJavaClassLoader();
+		loaders.add(loader);
+		
+		clazzes[0]=new MockJavaClass("a",loader);
+		clazzes[1]=new MockJavaClass("b",loader);
+		clazzes[2]=new MockJavaClass("c",loader);
+		loader.addClass(clazzes[0]);
+		loader.addClass(clazzes[1]);
+		loader.addClass(clazzes[2]);
+		heaps=new LinkedList<JavaHeap>();
+		MockJavaHeap heap=new MockJavaHeap();
+		heap.add(new MockJavaObject(clazzes[0]));
+		heap.add(new MockJavaObject(clazzes[1]));
+		heap.add(new MockJavaObject(clazzes[2]));
+		heaps.add(heap);
+		
+	}
+	@Override
+	public String getVersion() throws CorruptDataException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public String getFullVersion() throws CorruptDataException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Object getTraceBuffer(String bufferName, boolean formatted)
+			throws CorruptDataException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public List<JavaThread> getThreads() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public File getSource() {
+		
+		return source;
+	}
+
+	@Override
+	public JavaObject getObjectAtAddress(ImagePointer address)
+			throws CorruptDataException, IllegalArgumentException,
+			MemoryAccessException, DataUnavailable {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public List<JavaMonitor> getMonitors() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public JavaVMInitArgs getJavaVMInitArgs() throws DataUnavailable,
+			CorruptDataException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public ImagePointer getJavaVM() throws CorruptDataException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public List<JavaClassLoader> getJavaClassLoaders() {
+		
+		return loaders;
+	}
+
+	@Override
+	public List<JavaHeap> getHeaps() {
+		return heaps;
+	}
+
+	@Override
+	public List<JavaReference> getHeapRoots() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public List<JavaMethod> getCompiledMethods() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+}
\ No newline at end of file



Mime
View raw message