incubator-kato-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spo...@apache.org
Subject svn commit: r834075 - /incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/
Date Mon, 09 Nov 2009 14:18:52 GMT
Author: spoole
Date: Mon Nov  9 14:18:42 2009
New Revision: 834075

URL: http://svn.apache.org/viewvc?rev=834075&view=rev
Log:
changes to setup collector to use visitor

Added:
    incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/ExtractExternalSetupConfigVisitor.java
    incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/FileVisitorManager.java
    incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/IFileVisitor.java
    incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/LoadSetupClassesFileVisitor.java
    incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/LoadableClassFileVisitor.java
    incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/VisitStatisticsReporter.java
Modified:
    incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/ITestCaseVisitor.java
    incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/SetupCollector.java
    incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/VisitStatistics.java

Added: incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/ExtractExternalSetupConfigVisitor.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/ExtractExternalSetupConfigVisitor.java?rev=834075&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/ExtractExternalSetupConfigVisitor.java
(added)
+++ incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/ExtractExternalSetupConfigVisitor.java
Mon Nov  9 14:18:42 2009
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+package org.apache.kato.tck.harness;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.kato.tck.api.ISetup;
+
+/**
+ * 
+ */
+public class ExtractExternalSetupConfigVisitor extends
+		LoadSetupClassesFileVisitor {
+
+	MapCollector environmentVariables=new MapCollector();
+	ValueCollector systemProperties=new ValueCollector();
+	
+	public void handleSetupInstance(ISetup setup) {
+		
+		runSetupMethods(setup);
+		
+	}
+
+	public void runSetupMethods(ISetup setup) {
+	
+	
+		// get methods
+		Class me=setup.getClass();
+		Method m[] = me.getDeclaredMethods();
+	
+		
+		for (int j = 0; j < m.length; j++)
+		{
+			Method method=m[j];
+			String methodName=m[j].getName();
+			if (methodName.startsWith("env"))
+			{
+	
+				executeEnvMethod(method);
+	
+			}
+			else if (methodName.startsWith("jvm")) {
+				executeSysPropMethod(method);
+			}
+		}
+	
+	}
+
+	private void executeEnvMethod(Method method) {
+		try {
+			String[] result=(String[]) method.invoke(this, null);
+			if(result!=null && result.length>0) {
+				for(int r=0;r<result.length;r++) {
+					String var=result[r];
+					environmentVariables.collect(var,method);
+
+				}
+			}
+
+		} catch (SecurityException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (IllegalArgumentException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (IllegalAccessException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (InvocationTargetException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	
+	private void executeSysPropMethod( Method method) {
+		try {
+			String[] result=(String[]) method.invoke(this, null);
+			if(result!=null && result.length>0) {
+				for(int r=0;r<result.length;r++) {
+					String var=result[r];
+					systemProperties.collect(var,method);
+
+				}
+			}
+
+		} catch (SecurityException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (IllegalArgumentException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (IllegalAccessException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (InvocationTargetException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	public MapCollector getEnvironmentVariables() {
+		return environmentVariables;
+	}
+
+	public ValueCollector getSystemProperties() {
+		return systemProperties;
+	}
+	
+	
+
+}

Added: incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/FileVisitorManager.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/FileVisitorManager.java?rev=834075&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/FileVisitorManager.java
(added)
+++ incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/FileVisitorManager.java
Mon Nov  9 14:18:42 2009
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+package org.apache.kato.tck.harness;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Stack;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileSystemManager;
+import org.apache.commons.vfs.FileType;
+import org.apache.commons.vfs.VFS;
+import org.apache.kato.anttasks.tcklistbuilder.TCKDefinition.TCKClassDefinition;
+import org.apache.kato.tck.api.ISetup;
+
+/**
+ * Using the list of files provided as roots this class will visit all
+ * discovered classes which can actually be found on the class path
+ * 
+ */
+public class FileVisitorManager {
+
+	private FileSystemManager filemgr = null;
+	private Stack stack = new Stack();
+
+	public FileVisitorManager() throws FileSystemException {
+		filemgr = VFS.getManager();
+	}
+
+	/**
+	 * Entry point for visitor Pass in a collection of roots and a visitor
+	 * Understandable root types include File, ZipFile and JarFile
+	 * 
+	 * @param roots
+	 * @param handler
+	 * @return
+	 * @throws FileSystemException
+	 */
+	public VisitStatistics visit(Collection roots, IFileVisitor handler)
+			throws FileSystemException {
+
+		VisitStatistics stats = new VisitStatistics();
+		stats.roots = roots.size();
+		if (stats.roots == 0)
+			return stats;
+
+		handler.visitStarted();
+
+		Iterator i = roots.iterator();
+		while (i.hasNext()) {
+			Object root = i.next();
+			if (root instanceof String) {
+				String filename = (String) root;
+				root = filemgr.resolveFile(filename);
+			}
+			if (root instanceof FileObject) {
+				FileObject rootFile = (FileObject) root;
+				if (rootFile.exists() == false) {
+					stats.missingRoots++;
+				} else {
+					
+					if(rootFile.getType().equals(FileType.FOLDER)) {
+						rootFile=filemgr.createVirtualFileSystem(rootFile);
+					} 
+					stack.push(rootFile);
+					
+				}
+
+			} else {
+				stats.notroots++;
+			}
+		}
+
+		while (stack.isEmpty() == false) {
+
+			FileObject top = (FileObject) stack.pop();
+
+			if (top.getType() == FileType.FOLDER) {
+
+				stats.containers++;
+				if (handler.acceptContainer(top)) {
+					// add kids to stack
+					FileObject[] kids = top.getChildren();
+					if (kids != null) {
+						for (int k = 0; k < kids.length; k++) {
+							stack.push(kids[k]);
+
+						}
+					} else {
+						stats.ignoredContainers++;
+					}
+				}
+			} else {
+				// not a container - can we make it so?
+
+				if (filemgr.canCreateFileSystem(top)) {
+					if (handler.expandContainer(top)) {
+						top = filemgr.createFileSystem(top);
+						stack.push(top);
+						continue; // try again
+					}
+				}
+
+				// a "real" object
+				
+				stats.archiveEntries++;
+				if(handler.accept(top)) {
+					stats.matchedFiles++;
+					handler.visit(top);
+				}
+				else {
+					stats.unmatchedFiles++;
+				}
+			}
+
+		}
+		handler.vistEnded();
+
+		return stats;
+	}
+}

Added: incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/IFileVisitor.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/IFileVisitor.java?rev=834075&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/IFileVisitor.java
(added)
+++ incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/IFileVisitor.java
Mon Nov  9 14:18:42 2009
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+package org.apache.kato.tck.harness;
+
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSystemException;
+
+
+/**
+ * 
+ */
+public interface IFileVisitor {
+
+	
+	
+	boolean expandContainer(FileObject instance);
+	
+	boolean acceptContainer(FileObject instance);
+	
+	boolean accept(FileObject instance) throws FileSystemException;
+	
+	
+	/**
+	 * @param instance
+	 */
+	void visit(FileObject instance);
+
+	/**
+	 * 
+	 */
+	void visitStarted();
+
+	/**
+	 * 
+	 */
+	void vistEnded();
+
+}

Modified: incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/ITestCaseVisitor.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/ITestCaseVisitor.java?rev=834075&r1=834074&r2=834075&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/ITestCaseVisitor.java
(original)
+++ incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/ITestCaseVisitor.java
Mon Nov  9 14:18:42 2009
@@ -13,6 +13,8 @@
  ******************************************************************************/
 package org.apache.kato.tck.harness;
 
+import org.apache.kato.tck.tests.AbstractTCKTestcase;
+
 
 public interface ITestCaseVisitor {
 

Added: incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/LoadSetupClassesFileVisitor.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/LoadSetupClassesFileVisitor.java?rev=834075&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/LoadSetupClassesFileVisitor.java
(added)
+++ incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/LoadSetupClassesFileVisitor.java
Mon Nov  9 14:18:42 2009
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+package org.apache.kato.tck.harness;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.kato.tck.api.ISetup;
+
+/**
+ * 
+ */
+public class LoadSetupClassesFileVisitor extends LoadableClassFileVisitor {
+
+	
+	
+	public boolean acceptClass(Class clazz) {
+		
+		if(ISetup.class.isAssignableFrom(clazz) && clazz.equals(ISetup.class)==false) {
+			// its a match
+			try {
+				ISetup setup=(ISetup) clazz.newInstance();
+				handleSetupInstance(setup);
+				return true;
+			} catch (Exception e) {
+				e.printStackTrace();
+				
+			}
+		}
+		return false;
+	}
+
+	public void handleSetupInstance(ISetup setup) {
+		
+	}
+}

Added: incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/LoadableClassFileVisitor.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/LoadableClassFileVisitor.java?rev=834075&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/LoadableClassFileVisitor.java
(added)
+++ incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/LoadableClassFileVisitor.java
Mon Nov  9 14:18:42 2009
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+package org.apache.kato.tck.harness;
+
+import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSystemException;
+
+/**
+ * 
+ */
+public class LoadableClassFileVisitor implements IFileVisitor {
+
+	/* (non-Javadoc)
+	 * @see org.apache.kato.tck.harness.IFileVisitor#accept(org.apache.commons.vfs.FileObject)
+	 */
+	public boolean accept(FileObject instance) throws FileSystemException {
+		
+		FileName name=instance.getName();
+		String base=name.getBaseName();
+		if(base.contains("$")) return false;
+		
+		String extention=name.getExtension();
+		
+		if(extention.equals("class")==false) return false;
+		
+		String path = getClassName(instance);
+		Class clazz=loadClass(path);
+		if(clazz==null) return false;
+		return acceptClass(clazz);
+		
+	}
+
+	private String getClassName(FileObject instance) {
+		String path=instance.getName().getPath();
+		path=path.substring(0,path.length()-6);
+		path=path.replace('/','.');
+		path=path.replace('\\','.');
+		if(path.startsWith(".")) path=path.substring(1);
+		return path;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.kato.tck.harness.IFileVisitor#acceptContainer(org.apache.commons.vfs.FileObject)
+	 */
+	public boolean acceptContainer(FileObject instance) {
+		
+		return true;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.kato.tck.harness.IFileVisitor#expandContainer(org.apache.commons.vfs.FileObject)
+	 */
+	public boolean expandContainer(FileObject instance) {
+		// TODO Auto-generated method stub
+		return true;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.kato.tck.harness.IFileVisitor#visit(org.apache.commons.vfs.FileObject)
+	 */
+	public void visit(FileObject instance) {
+		
+		String path = getClassName(instance);
+		System.out.println(path);	
+		
+		
+	
+
+	}
+
+	/**
+	 * @param path
+	 * @return
+	 */
+	private Class loadClass(String className) {
+		try {
+			return Class.forName(className);
+			 
+		} catch (Throwable e) {
+		
+		return null;
+		}
+	}
+
+	public boolean acceptClass(Class clazz) {
+		
+		return true;
+	}
+	/* (non-Javadoc)
+	 * @see org.apache.kato.tck.harness.IFileVisitor#visitStarted()
+	 */
+	public void visitStarted() {
+		// TODO Auto-generated method stub
+
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.kato.tck.harness.IFileVisitor#vistEnded()
+	 */
+	public void vistEnded() {
+		// TODO Auto-generated method stub
+
+	}
+
+}

Modified: incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/SetupCollector.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/SetupCollector.java?rev=834075&r1=834074&r2=834075&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/SetupCollector.java
(original)
+++ incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/SetupCollector.java
Mon Nov  9 14:18:42 2009
@@ -21,9 +21,7 @@
 import java.util.LinkedList;
 import java.util.List;
 
-import org.apache.kato.anttasks.tcklistbuilder.TCKDefinition;
-import org.apache.kato.anttasks.tcklistbuilder.TCKDefinition.TCKClassDefinition;
-import org.apache.kato.tck.api.TCKConfiguration;
+
 
 import junit.framework.TestCase;
 
@@ -45,14 +43,33 @@
 	public static void main(String[] args) {
 
 		
-
+		List roots=new LinkedList();
 		
+		if(args==null || args.length==0) {
+			String path=System.getProperty("java.class.path");
+			String sep=System.getProperty("path.separator");
+			
+			while(true) {
+				int sepLoc=path.indexOf(sep);
+				if(sepLoc<0) {
+					roots.add(path);
+					break;
+				}
+			String prefix=path.substring(0,sepLoc);
+			roots.add(prefix);
+			path=path.substring(sepLoc+sep.length());
+			}
+		}
+		else {
+		for(int i=0;i<args.length;i++) {
+			roots.add(args[i]);
+		}
+		}
 		try {
 		    SetupCollector collector = new SetupCollector();
-		    if(args!=null && args.length>0) {
-		    	collector.setUserConfiguration(new File(args[0]));
-		    }
-			collector.collect(); 
+		    collector.collect(roots);
+		    collector.writeResults();
+		    
 		} catch (Throwable e) {
 			
 			e.printStackTrace();
@@ -63,54 +80,37 @@
 
 
 
-	public void extractRuntimeData(MapCollector envVars,
-			ValueCollector jvmArgs, AbstractTCKTestcase base) {
-		base.getEnvironmentArguments(envVars);
-		base.getJVMArguments(jvmArgs);
+	/**
+	 * 
+	 */
+	private void writeResults() {
+		// TODO Auto-generated method stub
+		
 	}
 
-	public void collect() throws IOException {
+
+
+
+
+	public void collect(List roots) throws IOException {
 
 		System.out.println("Collecter started");
 		
-		List testcaseAnchor=new LinkedList();
-		
-		TCKConfiguration config=getConfig();
-		
-		MapCollector envVars = new MapCollector(config.getEnvironmentalVariables());
-		ValueCollector jvmArgs = new ValueCollector(config.getJVMArguments());
-		
-		TCKDefinition def = config.getTestcaseConfiguration();
-		log("Definition date         = "+def.getCreatedDate());
 		
 		// gather and launch testcases
-		VisitStatistics stats=visitFiles(testcaseAnchor, def, envVars, jvmArgs);
+		ExtractExternalSetupConfigVisitor visitor=new ExtractExternalSetupConfigVisitor();
+		FileVisitorManager mgr=new FileVisitorManager();
+		VisitStatistics stats=mgr.visit(roots, visitor);
 		
 		
-		log("Classes found           = "+stats.classesFound);
-		log("Classes not found       = "+stats.classesNotFound);
-		log("Testcases found         = "+stats.testcasesFound);
+		log("Setup Classes found          = "+stats.matchedFiles);
 		log("End of Stats");
 		
-		if(stats.testcasesFound==0) raiseError("No testcases found");
+		if(stats.matchedFiles==0) raiseError("No testcases found");
+	
 		// write results
 		
-		File envlist=config.getEnvironmentalVariablesReportFile();
-		File jvmlist=config.getJVMArgumentsReportFile();
-		
-		log("writing env vars to "+envlist);
-		PrintWriter envWriter=new PrintWriter(new FileOutputStream(envlist));
-		writeData(envWriter, envVars.asList());
-		envWriter.close();
-		
-		PrintWriter argWriter=null;
-		if(jvmlist!=null) {
-			log("writing jvm args to "+jvmlist);
-			argWriter=new PrintWriter(new FileOutputStream(jvmlist));
-			writeData(argWriter, jvmArgs.asList());
-			argWriter.close();			
-		}
-		
+				
 
 		
 		 
@@ -121,62 +121,4 @@
 
 
 
-	private VisitStatistics visitFiles(final List anchor, TCKDefinition def, 
-			final MapCollector envVars, final ValueCollector jvmArgs) {
-		
-		VisitStatistics stats=new VisitStatistics();
-		
-		Iterator classes=def.classIterator();
-		while(classes.hasNext()) {
-			TCKClassDefinition clazz=(TCKClassDefinition) classes.next();
-			String qualifedName=clazz.getQualifedClassName(); 
-			Class realClass;
-			try {
-				realClass = Class.forName(qualifedName);
-				stats.classesFound++;
-			} catch (ClassNotFoundException e) {
-				stats.classesNotFound++;
-				 System.err.println("cannot find class "+qualifedName+" on classpath");
-					continue;
-			}
-			
-			
-			if(TestCase.class.isAssignableFrom(realClass)) {
-				stats.testcasesFound++;
-				TestCase instance;
-				try {
-					instance = (TestCase) realClass.newInstance();
-					
-				} catch (Exception e) {
-					stats.testcaseInstantiationFailures++;
-					System.err.println("Error instantiating "+qualifedName);
-					e.printStackTrace(System.err);
-					continue;
-				} 
-				if(instance instanceof AbstractTCKTestcase) {
-					extractRuntimeData(envVars, jvmArgs,(AbstractTCKTestcase) instance);
-					anchor.add(realClass);		
-				}
-			}
-			else {
-				 System.err.println("class "+qualifedName+" is not a Junit TestCase class");
-			}
-			
-		}
-		
-		return stats;
-	}
-
-	private void writeData(PrintWriter writer, List list) {
-		
-		
-		Iterator i=list.iterator();
-		while(i.hasNext()) {
-			String entry=(String) i.next();
-			writer.println(entry);
-		}
-		
-		
-		
-	}
 }

Modified: incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/VisitStatistics.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/VisitStatistics.java?rev=834075&r1=834074&r2=834075&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/VisitStatistics.java
(original)
+++ incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/VisitStatistics.java
Mon Nov  9 14:18:42 2009
@@ -13,19 +13,21 @@
  ******************************************************************************/
 package org.apache.kato.tck.harness;
 
-class VisitStatistics {
+public class VisitStatistics {
 
 	public int testcaseInstantiationFailures=0;
 	public int testcaseClassesAccepted=0;
 	public int testcasesFound=0;
-	public int classesFound=0;
-	public int classesNotFound=0;
+	public int matchedFiles=0;
+	public int unmatchedFiles=0;
 	public int archiveClassEntries=0;
 	public int archiveEntries=0;
 	public int fileRoots=0;
-	public int archiveRoots=0;
+	public int containers=0;
 	public int directoryRoots=0;
 	public int roots=0;
+	public int ignoredContainers=0;
+	public int notroots=0;
 	public int missingRoots=0;
 	
 }

Added: incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/VisitStatisticsReporter.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/VisitStatisticsReporter.java?rev=834075&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/VisitStatisticsReporter.java
(added)
+++ incubator/kato/trunk/org.apache.kato/kato.tck.harness/src/main/java/org/apache/kato/tck/harness/VisitStatisticsReporter.java
Mon Nov  9 14:18:42 2009
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+
+package org.apache.kato.tck.harness;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+/**
+ * 
+ */
+public class VisitStatisticsReporter {
+
+	private PrintStream out=null;
+	
+	public VisitStatisticsReporter() {
+		this(System.out);
+	}
+	/**
+	 * @param out2
+	 */
+	public VisitStatisticsReporter(PrintStream out) {
+		this.out=out;
+		}
+	public static void report(VisitStatistics stats) {
+		VisitStatisticsReporter reporter=new VisitStatisticsReporter();
+		reporter.reportStatistics(stats);
+	}
+
+	/**
+	 * @param stats
+	 */
+	public void reportStatistics(VisitStatistics stats) {
+		
+		out.println("Roots  :"+stats.roots);
+		out.println("Containers:"+stats.containers);
+		out.println("Ignored Containers:"+stats.ignoredContainers);
+		out.println("Matched Files:"+stats.matchedFiles);
+		out.println("unmatched Files:"+stats.unmatchedFiles);
+	}
+}



Mime
View raw message