incubator-kato-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spo...@apache.org
Subject svn commit: r835324 - in /incubator/kato/trunk/org.apache.kato/kato.anttasks/src: main/java/org/apache/kato/anttasks/tck/TCKSetupTask.java test/ant/testtags.xml
Date Thu, 12 Nov 2009 10:39:56 GMT
Author: spoole
Date: Thu Nov 12 10:39:56 2009
New Revision: 835324

URL: http://svn.apache.org/viewvc?rev=835324&view=rev
Log:
added support to specify config dir on tck setup task

Modified:
    incubator/kato/trunk/org.apache.kato/kato.anttasks/src/main/java/org/apache/kato/anttasks/tck/TCKSetupTask.java
    incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/ant/testtags.xml

Modified: incubator/kato/trunk/org.apache.kato/kato.anttasks/src/main/java/org/apache/kato/anttasks/tck/TCKSetupTask.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.anttasks/src/main/java/org/apache/kato/anttasks/tck/TCKSetupTask.java?rev=835324&r1=835323&r2=835324&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.anttasks/src/main/java/org/apache/kato/anttasks/tck/TCKSetupTask.java
(original)
+++ incubator/kato/trunk/org.apache.kato/kato.anttasks/src/main/java/org/apache/kato/anttasks/tck/TCKSetupTask.java
Thu Nov 12 10:39:56 2009
@@ -14,9 +14,15 @@
 
 package org.apache.kato.anttasks.tck;
 
+import java.io.DataInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Enumeration;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Properties;
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.taskdefs.Java;
@@ -33,6 +39,9 @@
 public class TCKSetupTask extends Java {
 
 	private boolean validateOnly=false;
+	private static File home=new File(System.getProperty("user.home"));
+	
+	private File configdir=null;
 	
 	private List envvars=new LinkedList();
 	private List scenerios=new LinkedList();
@@ -41,30 +50,122 @@
 		super.setFork(true);
 		super.setFailonerror(true);
 		super.setClassname("org.apache.kato.tck.harness.scenario.ScenarioLauncher");
+	
 	}
 
+	@Override
 	public void setFork(boolean s) {
 		throw new BuildException("cannot set fork on setup task");
 	}
 
+	
 	public void setFailonerror(boolean s) {
 		throw new BuildException("cannot set fail on error on setup task");
 	}
-
+	
 	public void execute() throws BuildException {
-		
-		configureScenerios();
-		
+	
+
 		
 		if(validateOnly) {
 			validate();
 			return;
 		}
-		// get env details etc
+		
+		// config for what we want to execute
+		
+		configureScenerios();
+		
+		// set home dir given
+		if(configdir!=null) {
+			
+			Argument arg=createArg();
+			arg.setValue("-configdir");
+			arg=createArg();
+			arg.setFile(configdir);
+		}
+		else {
+			configdir=new File(home,".tck");
+			
+		}
+		// add a parameter to ask for the env setup etc
+		Argument arg=createArg();
+		arg.setValue("-mode");
+		arg=createArg();
+		arg.setValue("config");
+		super.execute();
+		
+		// load in required files..
+		try {
+			applyEnvVarSettings();
+			applyJVMArgSettings();
+		} catch (IOException e) {
+			throw new BuildException(e);
+		}
+		
+		
+		// change param to run 
+		arg.setValue("run");
 		super.execute();
+	
 	}
 
 	/**
+	 * @throws IOException 
+	 * 
+	 */
+	private void applyEnvVarSettings() throws IOException {
+		File envfile=new File(configdir,"tck.envfile.txt");
+		if(envfile.exists()==false) return;
+		
+		FileInputStream fis=new FileInputStream(envfile);
+		Properties p=new Properties();
+		p.load(fis);
+		fis.close();
+		
+		Enumeration e=p.elements();
+		
+		while(e.hasMoreElements()) {
+			Object key=e.nextElement();
+			Object value=p.get(key);
+			 
+			Variable envvar=new Variable();
+			envvar.setKey(key.toString());
+			if(value!=null) {
+				envvar.setValue(value.toString());
+			}
+			else {
+				envvar.setValue("");
+			}
+			addEnv(envvar);
+		}
+		
+	}
+
+	/**
+	 * @throws IOException 
+	 * 
+	 */
+	private void applyJVMArgSettings() throws IOException {
+		File vmfile=new File(configdir,"tck.jvmfile.txt");
+		if(vmfile.exists()==false) return;
+		FileInputStream fis=new FileInputStream(vmfile);
+		DataInputStream dis=new DataInputStream(fis);
+		
+		while(true) {
+			String line=dis.readLine();
+			if(line==null) break;
+			Argument a=createJvmarg();
+			a.setValue(line);
+		}
+		
+		dis.close();
+		
+	}
+
+	/**
+	
+	/**
 	 * 
 	 */
 	private void configureScenerios() {
@@ -98,6 +199,7 @@
 			}
 		}
 		
+	
 		
 	}
 
@@ -119,6 +221,7 @@
 	}
 
 	
+	
 	public void setClassname(String s) throws BuildException {
 		throw new BuildException("cannot set classname on setup task");
 		
@@ -135,6 +238,7 @@
 		return validateOnly;
 	}
 
+	
 	public void addEnv(Variable var) {
 		
 		super.addEnv(var);
@@ -145,4 +249,7 @@
 		scenerios.add(s);
 	}
 
+	public void setConfigdir(File dir) {
+		configdir=dir;
+	}
 }

Modified: incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/ant/testtags.xml
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/ant/testtags.xml?rev=835324&r1=835323&r2=835324&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/ant/testtags.xml (original)
+++ incubator/kato/trunk/org.apache.kato/kato.anttasks/src/test/ant/testtags.xml Thu Nov 12
10:39:56 2009
@@ -15,6 +15,7 @@
 		<antcall target="tcksetup4" />
 		<antcall target="tcksetup5" />
 		<antcall target="tcksetup6" />
+		<antcall target="tcksetup7" />
 	</target>
 
 
@@ -68,5 +69,13 @@
 			</tcksetup>
 
 		</target>
+	<target name="tcksetup7">
+
+			<tcksetup validateonly="true" configdir="${user.home}">
+				<classpath path="${tests}" />
+				<scenario class="org.wibble.foo" />
+			</tcksetup>
+
+		</target>
 
 </project>
\ No newline at end of file



Mime
View raw message